⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shiti9_4_2.cpp

📁 为初学者提供的最佳的C++程序设计源程序库
💻 CPP
字号:
#include<iostream.h>
class Base
{
public:
	Base(int i){x=i;}
	int GetX(){return x;}
	void Print(){cout<<x<<endl;}
private:
	int x;
};
template<class T>
class Derived:public Base
{
  public:
	Derived(T a ,int j):Base(j){y=a;}
	T GetY(){return y;}
	void Print(){cout<<y<<" "<<GetX()<<endl;}
  private:
	T y;
};
void main()
{
	Base obj(123);
	obj.Print();
	Derived<int>D1(4567,8901);
	Derived<double>D2(2.3,4567);
	Derived<char*>D3("It is ",1234);
	Derived<char>D4('=',5678);
	D1.Print();
	D2.Print();
	D3.Print();
	D4.Print();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -