writing to static class member variable... 
Author Message
 writing to static class member variable...

Hi all,
        I need to assign different values to a static variable of a
class. The following code do not work:

class CSet
                static int count ;



int CSet::count = 0; // Is this line neccessary??



if ( type = = "DS")
CSet::count = 0;


The error message i got was :
unresolved external symbol "public: static int  CSet::count"

can someone tell me how to write to a static member?? I try declaring a
static member function and do the assignment inside it....and the same
problem still arise....i also try using friend static function and it
still won't work. btw, i am using VC++ 6.0

pls e-mail me in addition to the newsgroup.
Thanks in advance....
*As Imagination Bodies Forth
*The Forms Of Things Unknown, The Poet's Pen
*Turns Them To Shapes, And Gives To Airy Nothing
*A Local Habitation And A Name

Fri, 28 Sep 2001 03:00:00 GMT  
 writing to static class member variable...
#include "stdafx.h"
#include <iostream.h>
class CSet {
 static int count;

int CSet::count=2;
void main(void)
 cout<< CSet::count << endl;




"int CSet::count" must be implement in *.cpp file.
unresolved means that your static member variable is not implemented
by some reason.

The code above is compiled find by Visual C++ 6.0

Fri, 28 Sep 2001 03:00:00 GMT  
 [ 2 post ] 

 Relevant Pages 

1. write to static class member variable...

2. write to static class member variable....

3. static member variable inside class

4. LNK1169 & static const class member variables

5. Static member variables of template class

6. static template class member variable in DLL

7. static function access member variable and member function

8. does static class member change class size?

9. Class object as static member of another class

10. How to access a member variable of a class from other class

11. Classes as member variables of another class

12. Using a class as a member variable in the document class


Powered by phpBB® Forum Software