This is the mail archive of the gcc-help@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] | |
Thanks for the reference. It is good to go back to the C++ bible and refresh my memory. :)A private virtual function allows a derived class to implement behavior that is used by the base class. See C++PL 24.3.2.1
This is my first suspect. So I tried to add some other member functions into Base class, but failed to disturb the coincidence. Also, this works on both GCC 2.96 and MS C++ .NET, so I assume it is not compiler dependent.The situation you are describe relies on a happenstance where cavalier casting that relies on the serendipity that the signatures in the vptrtbl will happen to be in the same offset for the derived class as in the base class, and thus casting-with-the-big-hammer avoids the compiler catching the breach of access.
Casting in such a fashion is a source of bugs. Should be avoided.I strongly agree with you on this, and this is why I hoped the compiler would catch this in compile time and was suprised that it didn't.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |