c++ - Static function linker error -


i have followed these instruction:

is possible define static member function of class in .cpp file instead of header file? http://www.exforsys.com/tutorials/c-plus-plus/c-plus-plus-static-functions.html

however, example give gives me linker error:

"example::value", referenced from: example::printa()     in text.o example::printb()     in text.o ld: symbol(s) not found collect2: ld returned 1 exit status 

here text.h file:

class example {  public:      static int value;  public:      static void printa();     void printb();  }; 

and text.cpp file:

void example::printa() {      cout << value;  }  void example::printb() {      cout << example::value;  } 

how fix this, able print value both printa , printb? on mac os x 10.6.8 , xcode 3.2...

define static variable in cpp file.

int example::value; 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -