If I have this situation
class X
{
Z z;
Y y;
};
Class X has two objects of type Z and Y. How do I initialize z and y
with non default constructors?
X::X()
{
z(1);
y(2);
}
If I do something like the previous I get the following error:
line 2, Error: Could not find Z::Z() to initialize z.
line 2, Error: Could not find Y::Y() to initialize y.
line 3, Error: Only a function may be called.
line 3, Error: Only a function may be called.
class X
{
Z z;
Y y;
};
Class X has two objects of type Z and Y. How do I initialize z and y
with non default constructors?
X::X()
{
z(1);
y(2);
}
If I do something like the previous I get the following error:
line 2, Error: Could not find Z::Z() to initialize z.
line 2, Error: Could not find Y::Y() to initialize y.
line 3, Error: Only a function may be called.
line 3, Error: Only a function may be called.
Comment