B
barcaroller
I have an object ObjA (of class A) that contains another object ObjB (of
class B). When I construct object ObjA, I need to first get the value of x
before constructing an object B. I'm trying to avoid new() and delete().
How is it usually done?
class B
{
B(int y); // constructor
}
class A
{
A() // constructor
{
// first calculate x
int x = somefunc();
// then construct b
b(x); // wrong
}
B b;
}
class B). When I construct object ObjA, I need to first get the value of x
before constructing an object B. I'm trying to avoid new() and delete().
How is it usually done?
class B
{
B(int y); // constructor
}
class A
{
A() // constructor
{
// first calculate x
int x = somefunc();
// then construct b
b(x); // wrong
}
B b;
}