This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Calling a pure virtual function
- From: Florian Weimer <fw at deneb dot enyo dot de>
- To: Adam Nielsen <a dot nielsen at shikadi dot net>
- Cc: gcc at gcc dot gnu dot org
- Date: Sat, 09 Jul 2005 13:28:34 +0200
- Subject: Re: Calling a pure virtual function
- References: <20050709204147.0aaf5097.a.nielsen@shikadi.net>
* Adam Nielsen:
> class Base {
> public:
> Base()
> {
> cout << "This is class " << this->number();
> }
>
> virtual int number() = 0;
> };
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.
The following FAQ entry covers this:
http://www.parashift.com/c++-faq-lite/strange-inheritance.html#faq-23.3