when i call a member static function pointer which is initialized in constructor. it gives me unresolved external linking error.
any ideas?
thanks already
Printable View
when i call a member static function pointer which is initialized in constructor. it gives me unresolved external linking error.
any ideas?
thanks already
Static members cannot be initialized inside the class (save the few exceptions).
Meaning, it can only be initialized at definition(allocation).
Move your statement outside the class body.
let me give an example;
//class.h
class a
{
public :
a();
static int x;
static int (*y)(int z);
};
//class.cpp
int a::x = 0; /*this lets me to use x from everywhere*/
int (a::*y) = 0; /*when i try to reach y. now it gives unresolved external error*/
maybe i just need syntax to set function pointer some value.
Honestly I find function pointer syntax to be a pain and unintuitive....so whenever I need to use one, the first thing I do is typedef it. Once you do that then the definition would look like
Code:MyFunPtr a::myPtr = NULL;
thank you very much lindley