C
crea
I cannot find solution to this:
Here is the structure:
template <class T> class Data
{
public:
T p;
};
class AA
{
public:
// here I would like to have a data member: m_data
};
class BB : public AA
{
public:
};
If an object is create from AA then I want it to have member data object
created like this:
Data<int> m_data;
But if an object is created from BB then I want:
Data<string> m_data;
How to create a member data variable according to what class the object is
created from? Is this even possible?
Point is that for BB I want a data member of type "string" and for AA I want
a data member of type "int". And in both cases the data member name is
"m_data" and it is located in the class AA.
Here is the structure:
template <class T> class Data
{
public:
T p;
};
class AA
{
public:
// here I would like to have a data member: m_data
};
class BB : public AA
{
public:
};
If an object is create from AA then I want it to have member data object
created like this:
Data<int> m_data;
But if an object is created from BB then I want:
Data<string> m_data;
How to create a member data variable according to what class the object is
created from? Is this even possible?
Point is that for BB I want a data member of type "string" and for AA I want
a data member of type "int". And in both cases the data member name is
"m_data" and it is located in the class AA.