#include
#include
using namespace std;
template
y in_put(){
y a;
cout<<"please enter : ";
cin>>a;
return a;
}
int main(void){
// 调用形式有两种:
第1种形式:当函数里没有采用0个参数列表时
调用形式: 函数名<基础类型名>(); // 必须显式给出数据类型,否则编译系统无法推断虚拟类型的具体类型是什么。
第2种形式:当函数里采用了1+个参数列表时
调用形式: 函数名(参数列表); // 即不需要显式给出具体的数据类型
int i=in_put(); // y被int替代
string s=in_put(); // y被string替代
cout<<"s="<}
构造函数不用显式调用的。
A
如果上面这样产生对象,计算机就会调用你的那个构造函数了。