标签:names .net 解决 ble main clu jsb space namespace
分析以下程序出现的编译错误,给出解决的方案。
#include<iostream> using namespace std; //定义函数模板 template<class T> T max(T a, T b) { return (a>b)?a:b; } int main() { int x=2,y=6; double x1=9.123,y1=12.6543; cout<<"把T实例化为int:"<<max(x,y)<<endl; cout<<"把T实例化为double:"<<max(x1,y1)<<endl; return 0; }
#include<iostream> template<class T> T max(T a, T b) { return (a>b)?a:b; } int main() { int x=2,y=6; double x1=9.123,y1=12.6543; std::cout<<"把T实例化为int:"<<std::max(x,y)<<std::endl; std::cout<<"把T实例化为double:"<<std::max(x1,y1)<<std::endl; return 0; }
执行结果:
知识点总结:
解决冲突
标签:names .net 解决 ble main clu jsb space namespace
原文地址:http://www.cnblogs.com/mthoutai/p/6834522.html