R
Radde
Hello,
when i run the below code.. I get output
A()
A()
B()
C()
D()
dont know? why in this sequence?
#include<iostream.h>
class A
{
public:
A()
{
cout<<"A()"<<endl;
}
};
class B: public A
{
public:
B()
{
cout<<"B()"<<endl;
}
};
class C: public virtual A
{
public:
C()
{
cout<<"C()"<<endl;
}
};
class D: public B,public C
{
public:
D()
{
cout<<"D()"<<endl;
}
};
void main()
{
D d;
}
But when i make class B : public virtual A{}
and class C : public A(}
i get output
A()
B()
A()
C()
D()
how is this??
I get same output even if i dont use virtual inheritance(same as
above)..This is agreeable..But i dont know the first one and second
one?? I realy didnt understand the constructor calling mechanism..
Cheers..
when i run the below code.. I get output
A()
A()
B()
C()
D()
dont know? why in this sequence?
#include<iostream.h>
class A
{
public:
A()
{
cout<<"A()"<<endl;
}
};
class B: public A
{
public:
B()
{
cout<<"B()"<<endl;
}
};
class C: public virtual A
{
public:
C()
{
cout<<"C()"<<endl;
}
};
class D: public B,public C
{
public:
D()
{
cout<<"D()"<<endl;
}
};
void main()
{
D d;
}
But when i make class B : public virtual A{}
and class C : public A(}
i get output
A()
B()
A()
C()
D()
how is this??
I get same output even if i dont use virtual inheritance(same as
above)..This is agreeable..But i dont know the first one and second
one?? I realy didnt understand the constructor calling mechanism..
Cheers..