Re: Problem with virtual const

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

 



Hi Pierre,

Since the two functions have the same name (even though different
signatures), B will hide A's other g().

Here's how you tell the compiler that you actually want A's g() to be
visible in B:

class B : public A
{
  public:
    virtual ~B() {}
    virtual int g(int x) const {return x;}
    using A::g;
};

This behavior is in the language intentionally.  The rationale being (if I
recall correctly) is that for non-trivial projects it is desirable for the
compiler to flag situations where possible changes to the parent class
during on-going development may not yet be reflected in the child class.

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