S
sytee
i have the following and it compile no problem
example1:
-------------------------------------------------------------------------------
class Giant{
public:
Giant();
int getHeight(){ return height; }
private:
static int height;
};
-------------------------------------------------------------------------------
i try to change the style of example1 to
example2
-------------------------------------------------------------------------------
class Giant{
public:
Giant();
int getHeight(); // here we change
private:
static int height;
};
int Giant::getHeight() {return height;}
-------------------------------------------------------------------------------
there will be error message saying that:
test.obj : error LNK2001: unresolved external symbol "private: static
int Giant::height" (?height@Giant@@0HA)
how can i solve the problem by using back the example2 style?
thank you very much!!!
example1:
-------------------------------------------------------------------------------
class Giant{
public:
Giant();
int getHeight(){ return height; }
private:
static int height;
};
-------------------------------------------------------------------------------
i try to change the style of example1 to
example2
-------------------------------------------------------------------------------
class Giant{
public:
Giant();
int getHeight(); // here we change
private:
static int height;
};
int Giant::getHeight() {return height;}
-------------------------------------------------------------------------------
there will be error message saying that:
test.obj : error LNK2001: unresolved external symbol "private: static
int Giant::height" (?height@Giant@@0HA)
how can i solve the problem by using back the example2 style?
thank you very much!!!