static member variable not working with static member functions

Hello,

think its a lack of knowledge, but I have problem to realize the 
following szenario:

I have a class C. I have 2 member function F1 and F2. F1 is static F2 
not. I would like to access a static private member variable V1 from F1 
and F2, so in principle both are working on the same memory-physical 
variable. I don't get it work.
What is the right way to realize this?

Best Regards

0
ZZT
2/20/2004 11:47:19 AM
vc.mfc 33608 articles. 0 followers. Follow

5 Replies
587 Views

Similar Articles

[PageSpeed] 54

Something else must be at work here.  Both F1 and F2 should be able to
access the static member variable.

"ZZT" <a@b.c> wrote in message news:c14s48$66b$1@news1.wdf.sap-ag.de...
> Hello,
>
> think its a lack of knowledge, but I have problem to realize the
> following szenario:
>
> I have a class C. I have 2 member function F1 and F2. F1 is static F2
> not. I would like to access a static private member variable V1 from F1
> and F2, so in principle both are working on the same memory-physical
> variable. I don't get it work.
> What is the right way to realize this?
>
> Best Regards
>


0
2/20/2004 1:52:59 PM
Are you getting any linker errors/compiler errors.

Balaji

"ZZT" <a@b.c> wrote in message news:c14s48$66b$1@news1.wdf.sap-ag.de...
> Hello,
>
> think its a lack of knowledge, but I have problem to realize the
> following szenario:
>
> I have a class C. I have 2 member function F1 and F2. F1 is static F2
> not. I would like to access a static private member variable V1 from F1
> and F2, so in principle both are working on the same memory-physical
> variable. I don't get it work.
> What is the right way to realize this?
>
> Best Regards
>


0
me9459 (5)
2/20/2004 1:56:53 PM
ZZT wrote:
> I have a class C. I have 2 member function F1 and F2. F1 is static F2 
> not. I would like to access a static private member variable V1 from F1 
> and F2, so in principle both are working on the same memory-physical 
> variable. I don't get it work.

We need more info, like source code and what exactly isn't working 
(compiler, linker, or application behaves unexpectedly).

Is V1 really static? If it's not you can't use it from F1, and the 
compiler will complain.

Do you have definition of V1 (one line in C.cpp: C::V1;)? If you don't 
then V1 is only declared, but not defined, and the linker will complain.

0
mac1 (347)
2/20/2004 1:58:38 PM
Mihajlo Cvetanovic wrote:

 > Do you have definition of V1 (one line in C.cpp: C::V1;)?
 > If you don't then V1 is only declared, but not defined,
 > and the linker will complain.

thats it - thanks Mihajlo!
Of course, the definition in the header-file is only a definition, 
nothing physically.

bye

0
ZZT
2/20/2004 2:19:12 PM
Actually just the opposite.  Declarations typically go in the .H file, while
definitions typically go in the .C or .CPP file (these are not hard and fast
rules).  A definition is a must, while a declaration is nice to have.  A
definition can act as both as long as it's declared before it is used.  A
declaration establishes the name, return type, and parameter list of a
function.  In the case of a variable, only the first two apply.

"ZZT" <a@b.c> wrote in message news:c15511$bts$1@news1.wdf.sap-ag.de...
> Of course, the definition in the header-file is only a definition,
> nothing physically.
>
> bye
>


0
2/20/2004 6:07:31 PM
Reply:

Similar Artilces:

Rules not working consistently #2
Ok, Outlook 2003. I am getting a ton of junk mail for various ED medications (you know the medication that comes in a blue diamond shaped tablet) (see the last paragraph of this post). So I created a "rule" to delete any incoming message with in the subject. But the rule works inconsistently. Most such messages do get deleted, but not all of them. And I can't figure out why it's inconsistent. There is nothing wrong with rule; if I go into the Junk Mail Folder, and I "run rule now", it gets rid of those messages in the Junk Mail Folder with the medication&...

Calculating turaround time using IF function
I'm just learning to use the IF function, and it is not calculating correctly, so am looking for help. I'm using Excel 2000. For my spreadsheet, if a document is made available after 1700 hours or before 0700 hours the following day, I want it to calculate the turnaround time for those reports to begin at 0700 hours; otherwise calculate the remainder of the reports from the time the report became available to completion. Here's the IF statement I'm attempting to use with little success. E=Time report available I=Finish time =IF(OR(E>"17:00:00",E&l...

Disable COPY function
Does anyone know how can I avoid/restrict people Copying-n- pasting data from my excel spread-sheet. I am trying to lock down an excel spread-sheet to "Read Only" - in its true sense and dis-allow even copying data from this sheet to any other. Basically I want to turn off the COPY function. Secondly, if a person saves this sheet locally under another file name, how would I still disallow the COPY function. Is there any VBA module (which I can later password protect) which takes care of this. I do not have admin rights to set folder/file server permissions and the hiararch...

how to create chart with five data variables
I need to create a chart off of a spreadsheet with five variables I have to show: Room Fiscal Year (2003, 2004, 2005, 2006) Business Hour usage After-Hours usage Quantity (number of times the room was used that year) Currently I have the data as Fiscal Year in rows by Business or After Hours (FY03 Business Hours, FY03 After Hours, FY04 BH, FY04AH, etc.) Rooms in columns, and Quantity as cell value. What I want to do is create a stacked column chart that shows has Room for the X-axis value, Quanity for the Y-axis, Fiscal Year on the Z-axis (so it would be a 3-dimensional chart) and stack the ...

Reminders stopped working when data files were moved
My data files were moved from one server to another and then the reminders, for both tasks and calender ceased to work. Is there something about moving the files that can cause this? thanks John First thing to try is to open Outlook once with the /cleanreminders command line switch to see if it helps. Check out this article for more info: http://support.microsoft.com/kb/286166/en-us "Spider" <spiderspoon@hotmail.com> wrote in message news:jpvPf.967$dy4.78@news-server.bigpond.net.au... > My data files were moved from one server to another and then the > reminde...

DPM 2010 GUI crashes trying to add SQL Member
I have DPM 2010 installed and when I try to add a member with SQL 2008 installed to a protection group the GUI crashes every time. It crashes before you can even see what is available to backup. We have similar issues reported before. Look at the following thread: http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.dataprotectionmanager&tid=9409a3e4-83ee-4329-8610-dc2c9ba13e07&cat=en_US_c18d9b67-8a4f-493f-99fa-246042fd5824&lang=en&cr=US&sloc=&p=1 -- Santhosh Sivarajan | MCTS, MCSE (W2K3/W2K/NT4), MCSA (W2K3/W2K/MSG), C...

How to call a non static function from a static function
Hi I need to go to a non static function from a static function?can anybody suggest me how to do it?any kind of help will be greatly appreciated. You need to pass the object whose function you want to call. static void s_foo( A* a ); class A{ public: A(); ~A(); void funcA(); }; main() { ... A a; s_foo(&a); } static void s_foo( A* a ) { a->funcA(); } -Seetharam ...

Adding variables
How do I set up a query to add groups of variables? Say, for instance, I want to add the variables FO and FE and OC and CT and TB. Then I want to add FN and VG, etc. I'm not quite following ... Where are these "variables" coming from? Queries use data from tables (and from other queries)... Are you saying that you have multiple fields/columns and you wish to sum them? If so, that's how you'd do it in a spreadsheet ... and Access is NOT a spreadsheet! Using multiple columns to store different numbers means both you and Access will have to work over...

Catching messages of dynamically created CStatic members
Hi fellows. I have a CWnd-derived class that has two CStatic members, that are created dynamically. My question is simple: What must I do in order to receive messages of such members? This CWnd-derived class is for creating a custom control. This control needs vertical scrollbar, so I'm using two bitmaps, one as de up arrow and the other as the down arrow. I already placed them, now I need to receive the notification (the click notification). // in the header CStatic m_lblArrowUp; CStatic m_lblArrowDown; // in the Create method m_lblArrowUp.Create(_T(""), WS_CHILD | WS_VIS...

Static CMap object
Hi all, I've declared in my .h file the following CMap type : typedef CMap<CString, CString&, MyClass*, MyClass*&> Map; ... ... class AnotherClass { ... public: static TrainBuilderMap BuilderMap; ... ... static void Register(CString name, MyClass* instance); }; In one of my CPP file call the Register method as following: AnotherClass::Register(_T("TEST"), this); The code of Register method is : void AnotherClass::Register(CString name, MyClass* instance) { AnotherClass::BuilderMap.SetAt(name, instance); } When linking my project there the following linker error :...

Works spreadsheet #3
Now that my laptopn hard drive has been replaced, I no longer have Excel or Word(which was a surprise!). Will the included Works Spreadsheet work on my PC if I install Office 2003? -- Thanks, Ajimmo Hi Ajimmo, Works is a stand-alone programme and is not part of the Office suite. Conversely, Excel and Word are part of the Office suite; install Office 2003 and you can then use these programmes. --- Regards, Norman "ajimmo" <ajimmo@discussions.microsoft.com> wrote in message news:9D72774E-7643-48D5-8217-82C1A92864E1@microsoft.com... > Now that my laptopn hard dri...

Code working but not straight away!
This code is selecting all my check boxes after I have to close the form and re-open, can it be altered to work without closing and opening the formThanks for any help...........BobPrivate Sub Command19_Click()Dim strsql As Stringstrsql = "UPDATE tblHorseInfo SET tblHorseInfo.Worksheet = True"DoCmd.RunSQL strsqlEnd Sub NEVER MIND fixed already...Thanks Bob"Bob" <xxx@xx.xx> wrote in message news:et7d5o$gmt$1@lust.ihug.co.nz...>> This code is selecting all my check boxes after I have to close the form > and re-open, can it be altered to work without closing and...

Unable to get word files to work with windows computers
Hello, I have a quick question. I have word for my mac and I need to share word files with people who have word on windows computers. Is this possible? When I send them the file, they cannot open it. If it is possible to share, am I doing something wrong? Make sure the file has the .doc extension. There's no difference in the Word file format (since Word 97), so it's most likely a question of how the attachment is encoded by the email program. My Mac email program, Entourage, has this to say in Help: About attachment encodings When you choose an encoding format, it is helpful to u...

Working with external quoting systems
We have CRM 3.0, which is only used for contact management since we have developed other applications in MS Access 2003 for developing quotes and working with files from other software packages. The Access system fetches the customer information the the CRM database and that's just about all. We plan to migrate to CRM 4.0 and would like to keep the functionality of our rather complex quoting system, but have it more fully integrated so we can use all the opportunity management features and sales automation and reporting features. My guess is that we should try to re-write the quote ...

view excel vba code for built in functions
Anyone know how to view the code for the fuction Trim() or Trim$()? Specifically in Excel. It's not removing the &nbsp from html pages I copy forom, soI had to write my own code as a work around. So, I want to see the existing Trim() & Trim$() code to see if it is including the &nbsp in it's search for whitespace. ...

Parameter variables
Part of the DB I am working on contains a table for Emergency Response data. The primary key ([ERptNo]) is formatted as "yymmddhhmm_ _ _", the last 3 digits being the first 3 letters of the responders last name. If they were the Incident Commander, additional information is collected & added to the IC table, with a primary key ([ERNo]) of "yymmddhhmm". I've built a query with fields from these tables, and need to find a way to add parameters for a search which would open a report. I would like the IC report to show up as the first page, then all ...

Arrow Keys no Longer Work
I used to be able to hit the right and left arrow keys to move to the adjacent cells. Now it shifts the entire worksheet to the right or the left, and I can't figure out how to change it back. Thanks for any help. Go to the Tools menu, choose Options, then the Transition tab. There, uncheck Transition Navigation Keys. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "JDT" <jdten4@netscape.com> wrote in message news:k6u701dakd2l4mf0tt31s2b7agb2jq7n1t@4ax.com... >I used to be able to hit the right and left arrow...

Is the web-based interface to the microsoft.public groups working?
I was on this page: http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx and I selected (expanded) the microsoft.public.win98 tree (on the left side), and then went back (scrolled down) to select microsoft.public.win98.gen_discussion and after a minute or two I get this: -------------- Service Temporarily Unavailable We apologize for this inconvenience. Please try again later. --------------- I got this last night, and I'm getting it again just now. Is there some other way to bring up the microsoft web-interface to this group? YES Start here! htt...

Out of Office (OOF) not working
Hello OOF isnt working on one of our users mailbox, ie. she turns it on, but it doesnt auto reply. ive searched through the existing posts on solutions but still no joy. Ive disabled/re-enable OOF setting in Exchange admin. The user has no exisitng rules setup. The oof never worked so it cannot have been send one per user. Im using Exchange 2003 with Outlook 2003 clients. Any help, would help! thanks Jay If new mailboxes are working fine, you may want to take the simple "shotgun" approach of exporting the users data to PST, saving out the rules, and then creating a new mailbo...

SBS 2008
When trying to connect to any client on the network I get this error Your offer to help could not be completed. Either Remote Assistance is unable to find the remote computer or you do not have permissions to connect to the remote computer. Verify that the computer name and permissions are correct, and then try again. Event logs show this error Log Name: Microsoft-Windows-RemoteAssistance/Admin Source: Microsoft-Windows-RemoteAssistance Date: 12/05/2010 3:20:22 PM Event ID: 9 Task Category: None Level: Error Description: There was a probl...

Split variable and exec stored procedure
Hi all, having a variable with values separated by ; how can I split it to execute a stored procedure for each of them? Like declare @MyVariable varchar(50) set @MyVariable = 'value1;value2;value3' and exec MyStored for each of value1, value2, value3, etc. Thanks a lot. Luigi On Fri, 5 Feb 2010 01:18:01 -0800, Luigi wrote: >Hi all, >having a variable with values separated by ; >how can I split it to execute a stored procedure for each of them? > >Like > >declare @MyVariable varchar(50) >set @MyVariable = 'value1;value2;value...

Remove-RecoveryPoint does not work in DPM 2010
Dear experts, we've upgraded our DPM 2007 system to DPM 2010 RC last week (we need to protect Exchange 2010). Now 've tried to remove some recoverypoint from tape, because I have made an mistake in the backup schedule yesterday. I've used the common procedure: 1. $pg=get-protectiongroup 2. $ds=get-datasource $pg[3] 3. $rp=get-recoverypoint $ds[0] 4. remove-recoverypoint $rp[22] -forcedeletion I did not use -confirm:$False in order to have a last chance to check, if I delete the correct recovery point. What happens is: I can see, that it's the right recovery poi...

ssl does not work
when accessing owa, ssl does not work, i have an error msg saying that Server object error 'ASP 0178 : 80070005' Server.CreateObject Access Error /exchweb/bin/auth/owalogon.asp, line 4 The call to Server.CreateObject failed while checking permissions. Access is denied to this object. what can i do to fix this ?? please Check that you have ASP enabled on the server: Add and Remove Programs > Add and Remove Windows Components > Application Server 'Details' > Internet Information Services 'Details' > World Wide Web Service 'Details' >...

Reply feature not working
When I return an email using the Reply button the recipient does not get the reply. I have tried Requesting Notification but I don't get notified of delivery. I am running XP and using Outlook 2003 which is part of MS Office 2003 Teacher/Student Edition. Thanks in Advance Rob in Reno Sounds like your email cache is messed up. Delete the file C:\Documents and Settings\"your account"\Application Data\Microsoft\Outlook\Outlook.NK2 and then try it. "Rob in Reno" <RobinReno@discussions.microsoft.com> wrote in message news:63677527-82C3-4F80-A1E4-E74D1FD3E1AA...

SHRINK TO FIT doesn't work properly
The subject above says it all: Since switching to Excel 2003, text that USED to be displayed correctly (via the 'shrink to fit' in cell formatting)now doesn't appear to get shrunk at all. Rather, it bleeds over into the next column. Duuno how it got broken, but it would sure be nice if it could be fixed! Did you try re-formatting the selection? Sometimes that will fix the conversion problem. --- Message posted from http://www.ExcelForum.com/ As a matter of fact, YES, SEVERAL times. This is VERY peculiar behavior. The columns on either side of it are formatted as number...