H
Henrik Goldman
Hi,
Lets say I have a class a which looks like the following:
class a
{
public:
a(int i)
{
m_nI = i;
}
private:
int m_nI;
};
This class does not have a default constructor. Now I'd like to use the
class in class b as a member variable:
class b
{
private:
a m_a;
};
However since a needs a parameter to get constructed how can I specify this
as a part of class b? I know it's possible to initialize a by using a
pointer as member variable and e.g. new it inside the constructor but I'd
like to have a normal stack based variable.
How do I go about this?
Thanks in advance.
-- Henrik
Lets say I have a class a which looks like the following:
class a
{
public:
a(int i)
{
m_nI = i;
}
private:
int m_nI;
};
This class does not have a default constructor. Now I'd like to use the
class in class b as a member variable:
class b
{
private:
a m_a;
};
However since a needs a parameter to get constructed how can I specify this
as a part of class b? I know it's possible to initialize a by using a
pointer as member variable and e.g. new it inside the constructor but I'd
like to have a normal stack based variable.
How do I go about this?
Thanks in advance.
-- Henrik