C++继承的模板

it2022-05-05  90

#include <iostream> #include <string> #include <stdlib.h> using namespace std; template<typename T> class Father { public: T a; Father(T t) { a = t; } void show() { cout << a << endl; } }; class Son :public Father<int> { public: Son(int a):Father<int>(a) { } }; void main() { //在栈区 Son s1(458); s1.show(); system("pause"); }

最新回复(0)