barcaroller wrote:
> 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;
> }
;
Why can't you construct 'b' from the return value of 'somefunc'
in the 'A's initialiser list?
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask