given the following code:
myclass.h:
-------------------------------
class CMyClass
{
public:
CMyClass();
private:
static int test;
}
--------------------------------
myclass.cpp:
-------------------------------
#include "myclass.h"
CMyClass::CMyCl ass
{
CMyClass::test = 5; // error: unresolved external symbol
}
--------------------------------
I want to make a private member variable of static kind. What did I make
wrong? I always get the error message "unresolved external symbol".
I've already tried to access it via "this->test" but this doesn't work
either. Is it not allowed to access the static variable outside the same
file? What do I have to do in order to be able to access it from within my
member-functions?
any help is appreciated,
ekim
myclass.h:
-------------------------------
class CMyClass
{
public:
CMyClass();
private:
static int test;
}
--------------------------------
myclass.cpp:
-------------------------------
#include "myclass.h"
CMyClass::CMyCl ass
{
CMyClass::test = 5; // error: unresolved external symbol
}
--------------------------------
I want to make a private member variable of static kind. What did I make
wrong? I always get the error message "unresolved external symbol".
I've already tried to access it via "this->test" but this doesn't work
either. Is it not allowed to access the static variable outside the same
file? What do I have to do in order to be able to access it from within my
member-functions?
any help is appreciated,
ekim
Comment