I don't quite understand Multiple inheritance and virtual inheritance. plz help me. Here is my little test:
class Test1
{};
class Test21 : public Test1
{};
class Test22 : public Test1
{};
class Test3 : public Test21, public Test22
{};
int main()
{
Test1 * t1 = new Test3();
delete t1;
system("pause>NUL");
return 0;
}
I got an error: Error 1 error C2594: 'initializing' : ambiguous conversions from 'Test3 *' to 'Test1 *'.
WHY?
Then I tried like this:
class Test1
{};
class Test21 : virtual public Test1
{};
class Test22 : virtual public Test1
{};
class Test3 : public Test21, public Test22
{};
int main()
{
Test1 * t1 = new Test3();
delete t1;
system("pause>NUL");
return 0;
}
Now I got another error: Debug Assertion Failed!
Can someone explain me about Multiple inheritance and virtual inheritance?