函数模板
2014-01-16 18:57
162 查看
///////////////////////////function.cpp//////////////////////////
template < typename T >
string type(T t)
{
return Type<T>::name();
}
int main()
{
cout << type(123) << endl; // 对于函数模板,可以根据实参推测形参类型名
cout << type(45.6) << endl;
int a=10;
char b='k';
cout << type(a/1.0) << endl; // double
cout << type(a<b) << endl; // bool
cout << type<&a> << endl; // int pointer
}
template < typename T >
string type(T t)
{
return Type<T>::name();
}
int main()
{
cout << type(123) << endl; // 对于函数模板,可以根据实参推测形参类型名
cout << type(45.6) << endl;
int a=10;
char b='k';
cout << type(a/1.0) << endl; // double
cout << type(a<b) << endl; // bool
cout << type<&a> << endl; // int pointer
}
相关文章推荐
- easyUI 中datatGrid操作
- 寒假第三天--栈和队列--约瑟夫问题 (数组)
- 为什么开发人员工作10多年了还会迷茫?没有安全感?
- s5pv210 android4.0.3调试,如何去掉SGX540硬件加速
- 【机器学习】K-MEANS算法探究
- 维文新正字法
- CreateJS 与 Cocos2d-HTML5 的比较
- JsonMappingException: failed to lazily initialize及could not initialize异常
- Java 类设计技巧
- Java 类设计技巧
- 《苏菲的世界》~哲学是什么?
- BUG_学习随笔(移动数据快捷开关)
- 学习perl
- “贴身”研究UML
- PHP Swoole 基于纯真IP库根据IP匹配城市
- HDU 1259(水题)
- cygwin中添加sshd服务
- Word中插入公式后行距变宽的解决
- cocos2dx 动作
- java读取文本