this is example code that i got the error "undefined reference to`Parent::mMyClass'"
class Parent{ //A and B inherit Parent for mMyClass variable
protected:
enum MyClass{
ClassA,
ClassB,
};
static MyClass mMyClass;
};
class A : Parent {
public:
void setClass(){
mMyClass = Parent::ClassA; //Error Here
}
};
class B : Parent {
public:
void setClass(){
mMyClass = Parent::ClassB; //Error Here
}
};
int main()
{
A a;
B b;
a.setClass();
b.setClass();
return 0;
}
I am trying to share the variable "mMyClass" to use for class A and B. Any solution for solving this problem in a better way? Thanks