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]

Re: Problems invoking a member function through pointers.


> Date: Mon, 21 Dec 1998 23:08:06 -0600 (EST)
> From: <adriang@adriang.ce.mediaone.net>
> To: egcs@egcs.cygnus.com

> In the following code I would expect the output to be:
> Base::M1
> Base::M1
> Base::M2
> Base::M2

> To my surprise, the last line of the output says
> Derived::M2

This isn't the right group to learn C++ programming, comp.lang.c++ is
a better place.  Yes, this is what virtual means.  virtual means call
the most derived function in your class hierarchy.  If you don't want
that behavior, don't use virtual.

obj.Base::M2 () != obj .* (&Base::M2) ()


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