I ask because it doesn't seem to be for me. I've got a number of classes that inherit from a base class with some virtual functions. When I have a base class pointer everything works fine as it should. When I'm using the this pointer in the base class to call a virtual function it basically ignores the virtual part and treats the class as just normal inheiratance.
Is this the normal behavior for the this pointer? Seems kind of lame to me, what's the reasoning behind it (assuming this is the normal behavior)?
edit: I'll give an example for clairity
This would print:
[This message was edited by Screndib on February 24, 2002 at 09:51.]
Is this the normal behavior for the this pointer? Seems kind of lame to me, what's the reasoning behind it (assuming this is the normal behavior)?
edit: I'll give an example for clairity
code:<HR>Code:class A { public: virtual PrintMessage( void ) { cout << "Class A" << endl; } virtual DoSomething( void ) { this->PrintMessage(); } }; class B : public A { public: virtual PrintMessage( void ) { cout << "Class B" << endl; } }; A *pointer = new B; pointer->PrintMessage(); pointer->DoSomething();
This would print:
code:<HR>Code:Class B Class A
[This message was edited by Screndib on February 24, 2002 at 09:51.]