|
|
Darren New <dne### [at] sanrrcom> wrote:
> > The problem with calling a pure virtual function in the base class
> > constructor is that the derived class has yet not been initialized and
> > thus calling a derived class function implementation could cause undefined
> > behavior because it's not constructed.
> You mean, undefined behavior as opposed to a core dump? ;-)
Yes, undefined behavior. It could work like a charm, or it could cause
a segmentation fault. (The latter may easily happen if, for example, the
function in the derived class accesses eg. a string, which obviously has
not yet been initialized and contains garbage.)
--
- Warp
Post a reply to this message
|
|