This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Calling a pure virtual function


* 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]