#include <iostream>
using namespace std;
template<class T>
class Father {
public:
T a;
Father(T a) :a(a) {}
};
template<class T,class V>
class Son :public Father <V>{
public:
T a;
T b;
Son(T a,T b,V c) :a(a),b(b),Father<V>(c) {}
};
void test() {
Son<int, int> so(10, 20, 30);
cout << "so.a=" << so.a << " so.b=" << so.b << " so.Father.a=" << so.Father<int>::a << endl;
}
int main() {
test();
system("pause");
return EXIT_SUCCESS;
}
运行结果
so.a=10 so.b=20 so.Father.a=30
请按任意键继续. . .