-Woverloaded-virtual : why ?

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

 



Why does the following code generate an error ?
This error is described in the gcc manual under the C++ -Woverloaded-virtual
flag. I can't see why gcc can't generate a call to A::f(Y). This exactly
against the behaviour one would expect under the basic principles of
polymorphism.
(gcc 3.4.3).


struct X{};
struct Y{};
struct Z{};

struct A
{
    virtual void f(X);
    virtual void f(Y);
    virtual void f(Z);
};

struct B: public A
{
    virtual void f(X);
};

void Test (void)
{
    B b;
    X x;
    Y y;

    b.f(x);
    b.f(y);     // error: no matching function for call to 'B::f(Y&)'
}

--
Matthew JONES
http://www.tandbergtv.com/


[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