This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Calling a pure virtual function
> Roughly speaking, when number() is invoked, the object still has type
> Base (with a corresponding vtable). One's constructor will change the
> type once the Base part has been constructed.
Aha yes, I didn't even think of that! Thanks Florian and Lion for your
helpful answers!
> The following FAQ entry covers this:
> http://www.parashift.com/c++-faq-lite/strange-inheritance.html#faq-23.3
Hmm, I should've read just a little further... ;-)
It still makes me wonder whether GCC is reporting the correct error for
this mistake though, I would've expected a compiler error (something
along the lines of 'you can't call a pure virtual function') rather than
a linker error. Especially as GCC should be able to tell at compile
time the base constructor is calling a pure virtual function. I guess
it's treating the constructor like any other function, where this
behaviour would be permitted.
Either way, that solved the problem for me, so thanks again!
Cheers,
Adam.