This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/32934] No warning when creating a non const derived funtion from a const virtual funciton



------- Comment #1 from pinskia at gcc dot gnu dot org  2007-07-30 02:19 -------
Well it is valid as B::print hides A::print.
Try doing:
#include <iostream>
class A {
public:
    virtual char * print() const { return "A\n";}
    virtual ~A(){};
};
class B : public A {
public:
    virtual char * print() { return "B\n";}
    using A::print;
    virtual ~B(){};
};

int main ()
{
    B b;
    A & a = b;
    const B &b1 = b;
    std::cout << a.print() << b1.print();
}

Which shows that b1.print will call A::print.  If you don't include using
A::print, then A::print wil be hidden in B.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32934


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]