Hi,
is there a (practicable) way to by-pass the normal (virtual) constructor calling order? (Hard to describe in one sentence, see the)
Example:
class A
{
const int i;
public:
A()
: i(0)
{ cout << "calling A()" << endl; }
A(int p)
: i(p)
{ cout << "calling A(int)" << endl; }
};
class B
: public...
I have the code below:
class A
{
};
class B: public virtual A
{
public:
B()
{
cerr << "B()";
}
B(const A& a)
{
cerr << "B(const A&)";
}
};
class C: public B
{
};
int main(int argc, char **argv)
{
B *b = new B(C());
}
To my surprise B(const A& a) isn't called. Why is that?
...
Possible Duplicate:
In C++ virtual base class?
The virtual keyword is used to remove the ambiguity, but how does it actually work?
I have four classes: a, b, c, and d.
I am doing:
class a
{public int a;};
class b: virtual public a
{};
class c: virtual public a
{};
class d:public b,public c
{};
This works, but what actu...
consider the following code:
class A
{
friend class B;
friend class C;
};
class B: virtual private A
{
};
class C: private B
{
};
int main()
{
C x; //OK default constructor generated by compiler
C y = x; //compiler error: copy-constructor unavailable in C
y = x; //compiler error: assignment operator unavailable in...