I’m trying to do multiple inheritance in C++:
class Element{
public:
Element(): common_variable(0) {}
int common_variable;
};
class Number:public Element, public Setupable{
public:
Number() {}
vector<Digit> digit_vector;
};
class MultiLed:public Element, public Setupable{
public:
MultiLed() {}
vector<Led> led_vector;
};
The object Element is never instanciated but I use it to avoid code repetition in Multiled and Number.
There is a map that include a Number : map<string,Number> mNumbers, and I would like it to be created at the first use:
mNumbers["blabla"].digit_vector.push_back(digit);
But this doesn’t work. The call to the constructors of Element, Setupable and Number is correctly done. But the programs stops at the “push_back” call saying :
undefined symbol: _ZN14AcElementD2Ev
Can someone help me with this?
As you didn’t post all code, I have to guess the situation in your code. I’ll update my answer when you update the question.
Most likely, you have declared a static member in Element, the name is likely to be
D2Ev, but you forgot to provide a definition for it.When you define base class, don’t forgot to declare virtual destructor.