Re: How to declare pointers to virtual base class methods ?
- From: "Gene Bushuyev" <gb@xxxxxxxxx>
- Date: Tue, 12 Apr 2005 18:43:37 GMT
Reconsider your design. Apart from compiler being unable to cast member
pointers, your design invokes undefined behavior and even if you make it
compile it will crash and burn one day.
You'are trying to establish callbacks to the derived class member functions.
That should immediately be a red flag for you. My experience tells me that
when people start employing callbacks, that usually indicates a faulty
design, or deficiencies of the language (e.g. lack of natural event
support), or crossing language boundaries (e.g. c/c++)
Probably in your case you need to design a clear base class interface with
virtual functions that will be overridden as necessary in derived classes.
Gene
"Ingo" <Ingo@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2D76B748-E0C6-44E9-A144-C428734C471C@xxxxxxxxxxxxxxxx
> Hi All!
>
> I have a problem in using pointers to methods of a base class.
> I define two classes A and B where B inherits from A. Class A has a method
> that takes a pointer to a method of A as an argument. Even if I apply this
to
> a class B derived from A, everything works fine (however an explicit type
> casting to the method pointer type of class A is necessary).
>
> Now here is my problem:
> The class structure makes usage of multiple inheritance and virtual
classes.
> If we now declare the inherited class A as virtual, the compiler does not
> accept the method pointer types anymore and throws an error.
.
- References:
- Prev by Date: Re: How to declare pointers to virtual base class methods ?
- Next by Date: Re: C++ compiler bug creates corrupted library
- Previous by thread: Re: How to declare pointers to virtual base class methods ?
- Next by thread: Java outperforms C++?
- Index(es):
Relevant Pages
|