support bazel complie this project and format code.

This commit is contained in:
zhangxing
2023-03-30 00:15:11 +08:00
committed by light-city
parent 1f86192576
commit 3c8a3f259b
641 changed files with 10349 additions and 9523 deletions

View File

@@ -0,0 +1,39 @@
/* 派生类初始化.cpp */
#include <iostream>
using namespace std;
class A {
int a;
public:
A(int x) {
a = x;
cout << "Virtual Bass A..." << endl;
}
};
class B : virtual public A {
public:
B(int i) : A(i) { cout << "Virtual Bass B..." << endl; }
};
class C : virtual public A {
int x;
public:
C(int i) : A(i) {
cout << "Constructing C..." << endl;
x = i;
}
};
class ABC : public C, public B {
public:
//虚基类由最终派生类初始化
ABC(int i, int j, int k)
: C(i), B(j), A(i) // L1这里必须对A进行初始化
{
cout << "Constructing ABC..." << endl;
}
};
int main() {
ABC obj(1, 2, 3);
return 0;
}