CPlusPlusThings/practical_exercises/10_day_practice/day5/虚拟继承/例2.cpp
Light-City a4d828bb4c update
2020-04-06 00:57:02 +08:00

19 lines
279 B
C++

#include<iostream>
using namespace std;
class A {
public:
void vf() {
cout<<"I come from class A"<<endl; }
};
class B: virtual public A{};
class C: virtual public A{};
class D: public B, public C{};
int main()
{
D d;
d.vf (); // okay
system("pause");
return 0;
}