|
|
Warp wrote:
> I think that error happens if you try to call a pure virtual function
> in the initialization list of the base class constructor. (What I really
> don't understand is why it isn't a compile-time error...)
Just to check, by "pure virtual function", you mean the kind of thing
that leads to the class being abstract? A function like
virtual int func() = 0;
or whatever the syntax is?
Oh, right, OK. So it's called in the constructor of the class that
actually implements the virtual function, except it's called before the
child's constructor actually gets entered, so the vtable pointer is
still pointing to the parent's vtable or whatever so the parent has the
right offsets for its stuff, ....
I can see where catching that would be difficult. If the constructor
calls x(), and x() calls y(), and y() is abstract in the parent class,
C++ is going to invoke a function whose definition isn't there.
Most other languages don't futz with the class of the object while it's
being constructed, so it doesn't really come up, I guess. One of the
costs of multiple inheritance as implemented by C++?
--
Darren New / San Diego, CA, USA (PST)
Remember the good old days, when we
used to complain about cryptography
being export-restricted?
Post a reply to this message
|
|