Re: Inheritance problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Bernhard,

> In don't really understand what's going wrong, because b is of type A, so
> there should be a function void foo() to call. That'S what inheritance is all
> about. But why doesn't it work and can I change this behavior somehow?

It doesn't work because B's foo method hides A's foo method.

Add this to B:
class B : public A
{
 ...
using A::foo;
 ...
};

However, the better way to fix the problem is to change the method name of
the non-virtual method so that they do not collide.

Overloading methods is a powerful, but dangerous, capability.  It should not
be used casually.

HTH,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux