Hi all!
I have a problem with Visual Studio 2008 concerning virtual inheritance.
Consider the following example:
#include<iostream>
class Print {
public:
Print (const char * name) {
std::cout << name << std::endl;
}
};
class Base : public virtual Print {
public:
Base () : Print("Base") {}
};
class A : public Base {
public:
A () : Print("A") {}
};
class B : public A {
public:
B () : Print("B") {}
};
int main (int argc, char** argv) {
A a; // should print "A"
B b; // should print "B"
return 0;
}
This code compiles just fine if I use gcc on my linux machine. But if I try to build the same on windows with Visual Studio, the compilation fails with error message "error C2614: 'B': illegal member initialization: 'Print' is not a base or member."
Why does this not work?