c++多重继承

可以在子类中通过基类名访问函数

// oj4.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include<iostream>
#include<vector>
using namespace std;
class A{

public:
A(){ cout << "A" << endl; }
int a;
virtual void play(){ cout << "i am in A" << endl; }
void set(int _a)
{
this->a=_a;
}
};
class B: public A
{
public:
B(){ A::set(8); cout << "B" << endl; }
void play(){

}
};
class C : public A
{
public:
C(){ A::set(7); cout << "C" << endl; }
void play()
{

}
};
class D :public C, public B
{
public:
D(){ cout << "D" << endl; }
void play()
{
cout <<C::a << endl;
}
};
int main()
{
D d;
d.play();
return 0;
}

/*

"aaa","ab*ac*a"

*/

上一篇:Linux防火墙配置—SNAT2


下一篇:判断一个js对象,是否具有某个属性