[C++] decltype(auto) C++ 11 feature
2015-10-27 13:22
316 查看
1 //C++ 11 feature template <class T1, class T2> auto getMultiply(T1 data1, T2 data2) -> decltype(data1*data2) { return data1*data2; } int main() { //cout << getResult<int>(3,3,4,5) << endl; cout <<getMultiply(12.2, 13.3)<< endl; cout << typeid(getMultiply(12.2, 13.3)).name() << endl; system("pause"); }
auto : Deduce the type of data based on actual data
auto is not allowed to be used as a function parameter
相关文章推荐
- 【ACM】1044:最小最大数兑换
- 【ACM】1043:字符串排序
- 【ACM】1020:迭代法
- C++
- Day6.15 C语言递归函数概念以及应用
- 嵌入式开发人才的未来发展方向
- 如何养成良好的 C++ 编程习惯—— 内存管理
- [C++] Template Function _ Any number of parameters
- 2、C语言基础
- C++设计模式之适配器模式(改编自C++设计模式)
- c++ vector
- C++中的函数重载
- C语言中的far关键字
- c++实现tailf命令
- 加密与解密:一个简单的C语言示例
- 经验积累之C语言与汇编语言的区别
- FIR IIR 数字滤波器 C++实现
- C++中的extern "C" {}
- C++ string数据类型的实现
- CCPC - k题(dp)