C++ typedef static function pointer: undefined symbol -


//class.h  typedef double (*ffunct)(double x1, double y1, double x2, double y2);  class class {     public:         static ffunct myfunct;         static void setfunct();         static double dosomething(double x1, double y1, double x2, double y2);         static void call();  }   //class.cpp  void class::setfunct(){      class::myfunct=class::dosomething;  }  double class::dosomething(double x1, double y1, double x2, double y2) {      cout << "hello world" << endl;  }  void class::call() {      class::myfunct(1.0,2.0,3.0,4.0);  }  //main.cpp  …  class::setfunct();  class::call();  …  

running programm results in undefined symbols architecture x86_64: "class::myfunct", referenced class::setfunct, class::call…

so doing wrong?

in cpp file need 1 more line:

ffunct class::myfunct = null; 

the class declaration said variable exist somewhere never gave definition. since it's not part of each object has defined separately.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -