Logo Search packages:      
Sourcecode: gcc-2.95 version File versions

bug-35477.cc

#include <iostream.h>

class A
{
public:

        A() { a=1; bar(); };
        virtual void foo() {
                cout << "A::foo  " << this << ' ' << a << endl; };
        void bar() { foo(); };

private:

        int a;
};

class B : virtual public A
{
public:

        B() { b=1; bar(); };
        virtual void foo() {
                cout << "B::foo  " << this << ' ' << b << endl; };

private:

        int b;
};

class C : virtual public A
{
public:

        C() { c=1; bar(); };
        virtual void foo() {
                cout << "C::foo  " << this << ' ' << c << endl; };

private:

        int c;
};

class D : public B, public C
{
public:

        D() { d=1; bar(); };
        virtual void foo() {
                cout << "D::foo  " << this << ' ' << d << endl; };

private:

        int d;
};

class E : public D
{
public:

        E() { e=1; bar(); };
        virtual void foo() {
                cout << "E::foo  " << this << ' ' << e << endl; };

private:

        int e;
};

int
main()
{
        cout << "starting test" << endl;
        E e;
        cout << "object constructed" << endl;
        e.bar();
        cout << "test finished" << endl;
        return 0;
}

Generated by  Doxygen 1.6.0   Back to index