B
BosByte
Hello,
Please take a look at this well-known 'problem':
----------------
class A{
B * foo();
};
class B{
A * foo();
};
----------------
Its solution is simple: add "class B;" above A.
But here's a smilar, but more complex, problem:
----------------
class A_1 {
virtual B_1 * foo();
};
class B_1{
virtual A_1 * foo();
};
class A_2 : public A_1 {
virtual B_2 * foo(); //Overrides foo() of A_1. The return-type is
different, but it's okay because B_2 is a derivative of B_1
};
class B_2 : public B_1 {
virtual A_2 * foo(); //Overrides foo() of B_1. The return-type is
different, but it's okay because A_2 is a derivative of A_1
};
----------------
Adding "class B_1; class B_2;" on top of it doesn't solve the problem,
because the compiler only accepts the first override if it knows that
B_2 is a derivative of B_1.
How do I tell the compiler that B_2 is a derivative of B_1, without
having to specify all the contents of B_2 ?
Thanks in advance,
-Maurice-
Please take a look at this well-known 'problem':
----------------
class A{
B * foo();
};
class B{
A * foo();
};
----------------
Its solution is simple: add "class B;" above A.
But here's a smilar, but more complex, problem:
----------------
class A_1 {
virtual B_1 * foo();
};
class B_1{
virtual A_1 * foo();
};
class A_2 : public A_1 {
virtual B_2 * foo(); //Overrides foo() of A_1. The return-type is
different, but it's okay because B_2 is a derivative of B_1
};
class B_2 : public B_1 {
virtual A_2 * foo(); //Overrides foo() of B_1. The return-type is
different, but it's okay because A_2 is a derivative of A_1
};
----------------
Adding "class B_1; class B_2;" on top of it doesn't solve the problem,
because the compiler only accepts the first override if it knows that
B_2 is a derivative of B_1.
How do I tell the compiler that B_2 is a derivative of B_1, without
having to specify all the contents of B_2 ?
Thanks in advance,
-Maurice-