Topic: virtual functions not overridable anymore?


Author: Gerard Weatherby <gerardw@alum.mit.edu>
Date: 1997/09/08
Raw View
"Alexander Jung" <jung@new-line.de> wrote:

Cristian Georgescu <Cristian.Georgescu@worldnet.att.net> schrieb im
Beitrag

> Is there a way to specify that a virtual function should not be
> overridden anymore?
>
> (The function is declared as virtual in the base class, and overridden in
> the derived class, but I want that the classes derived from this class
> not to override function anymore).

put the member in the private part of your class declaration and add a
public non-virtual member that calls the virtual method if you still
want
to call it.

bye, AJ
-------------------
Non-intuitivity perhaps, but you CAN override a private base class
method.  You just can't call it.
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]





Author: "Alexander Jung" <jung@new-line.de>
Date: 1997/08/28
Raw View
Cristian Georgescu <Cristian.Georgescu@worldnet.att.net> schrieb im Beitrag

> Is there a way to specify that a virtual function should not be
> overridden anymore?
>
> (The function is declared as virtual in the base class, and overridden in
> the derived class, but I want that the classes derived from this class
> not to override function anymore).

put the member in the private part of your class declaration and add a
public non-virtual member that calls the virtual method if you still want
to call it.

bye, AJ
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]