This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: C++ question: MI vs. pure virtuals
According to llewelly@198.dsl.xmission.com:
> On Fri, 31 Dec 1999, Chip Salzenberg wrote:
> > class A { virtual void f() = 0; }; // PURE VIRTUAL
> > class B { void f() {} }; // NON-VIRTUAL
> > class C {}; // ??
> >
> > Is class C abstract like A, or not?
>
> So I am going to assume you meant to ask about this:
>
> struct A {virtual void f()=0;};
> struct B {void f() {}};
> struct C :public A,public B {};
D'oh! Yes. Consider that my mistake for this millenium (GMT). :-)
> Since A is not a base class of B, B::f() does not overide (does not
> implement) A::f(). (See sections 10.2, p2 (for name lookup), 10.3 p2,
> (for overriding of virtual functions) 10.4 (abstract base classes), and
> pay particular attention to all of the examples in these sections.)
Thank you for the precise answer. I shall examine those sections.
In a related question, a slight variation that I tried with gcc 2.96 is:
struct A {virtual void f()=0;};
struct B {void f() {}};
struct C : public A, public B { using B::f; };
That didn't work either (the compiler still considered C abstract).
To your understanding, is the compiler still correct in this case?
(I expect that it is, but it doesn't hurt to ask.)
--
Chip Salzenberg - a.k.a. - <chip@valinux.com>
"Fleagal. Bingo. Drooper. Snork. They're cops." //MST3K