Re: why make non-pure virtual functions?

From: jeffc (nobody_at_nowhere.com)
Date: 03/15/04


Date: Mon, 15 Mar 2004 15:24:28 -0500


"Pete Vidler" <pvidler@mailblocks.com> wrote in message
news:NMn5c.41$jr2.23@newsfe1-win...
> jeffc wrote:
> [snip]
> >>Right. I think it would have been better to require the virtual keyword
> >>in all the derived classes. If you don't specify 'virtual' in the
> >>derived class, and someone looks at that class's header, he won't know
> >>which of the member functions are re-implementations of virtual member
> >>functions. He would first have to go up the inheritance tree and search
> >>through all the base classes to find that out.
>
> [snip]
> > void f() {
> > cout << "A::f" << endl;
> > }
> [snip]
>
> You have to specify it as virtual in the base class. If it's left out in
> the *derived* class there is no difference.

My point is you still have to look at the base class regardless of how it's
defined in the subclass.



Relevant Pages

  • Re: Drawing a line
    ... The place where you create new classes is where you specify the base class, ... How do I create a "subclass" of CStatic? ... if you want a "line" that is 256 pixels long where each pixel ...
    (microsoft.public.vc.mfc)
  • Re: why make non-pure virtual functions?
    ... You have to specify it as virtual in the base class. ... intended to create a new virtual method but didn't notice there was one ...
    (comp.lang.cpp)
  • RE: Serializing of inherited Classes
    ... I understand that when you specify the base class to ... XmlIncludeAttribute, an exception was thrown. ... we have to specify the Type of the derived class. ...
    (microsoft.public.dotnet.xml)
  • Why cant static methods be overridden?
    ... Quite often I have a hierarchy of classes where ... I want a specific accessor method to be ... Therefore I specify ... it in the base class. ...
    (comp.lang.java.programmer)
  • Re: Can someone tell me what this syntax does please?
    ... >> you're in) both define the same function, so you want to specify that ... > in any base class the current object might descend from. ... void f); ...
    (comp.lang.cpp)