📄 ch16_01.cpp
字号:
#include<iostream>
using namespace std;
template<class anyType>
anyType equation(anyType x)
{
anyType y;
y=x*x*x-3;
return y;
}
int main()
{
int i_ans;
int i_x=10;
i_ans=equation(i_x);
cout<<"formua y=2(x*x)-3"<<endl;
cout<<"int ans="<<i_ans<<endl;
cout<<"----------------"<<endl;
float f_ans;
float f_x=3.3;
f_ans=equation(f_x);
cout<<"formula y=2(x*x)-3"<<endl;
cout<<"float ans="<<f_ans<<endl;
cout<<"----------------"<<endl;
double d_ans;
double d_x=9.23586784;
d_ans=equation(d_x);
cout<<"formula y=2(x*x)-3"<<endl;
cout<<"double ans="<<d_ans<<endl<<endl;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -