Re: Constructor Behaviour
Andrew Tomazos wrote:
Please consider the following code...
class A {...}
class B {...}
class C
{
public:
virtual void f();
A a;
C(...)
: a(...)
{ ... }
}
class D : public C
{
public:
virtual void f();
B b;
D(...)
: C(...)
, b(...)
{
...
point1: ;
}
}
void t()
{
D* d = new D();
point2: ...;
}
My question is about the difference in the concrete state of the D
instance between point1 and point2. Namely just before the final
constructor exits (point1) and just after new returns (point2).
One difference is that at point1 the object is not fully constructed.
At point2 it is.
If you throw an exception at point1, this difference will be very
visible in that the object will *never* be fully constructed.
Is there any code automatically generated by the compiler to do with
setting up the object (for example to do with RTTI, the vtable,
anything?) that executes between point1 and point2 in the above
example?
The standard doesn't say anything about that. If there is, that is all
implementation specific.
Bo Persson
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]