标题:类模板的问题,调试出错
只看楼主
zhy0401052
Rank: 1
等 级:新手上路
帖 子:27
专家分:2
注 册:2009-7-19
结帖率:87.5%
已结贴  问题点数:20 回复次数:1 
类模板的问题,调试出错
#include<iostream>
using namespace std;
template <class numtype>
class compare
{
public:
compare(numtype a,numtype b)
{x=a;y=b;}
numtype max()
{return(x>y)?x:y;}
numtype min()
{return(x<y)?x:y;}
private :
    numtype x,y;
};
int main()
{compare <int> cmp1(3,8);
cout<<cmp1.max()<<"is the max"<<endl;
compare <float> cmp2(14.5,16.8);
cout<<cmp2.max()<<"is the max"<<endl;
compare <char> cmp3('a','b');
cout<<cmp3.max()<<"is the max"<<endl;
return 0;
}
哪位兄弟帮忙看下,在运行的时候有两个错误。谢谢了!
搜索更多相关主题的帖子: 类模板调试 
2009-08-09 21:10
tjp1984
Rank: 2
来 自:河南
等 级:论坛游民
帖 子:137
专家分:39
注 册:2009-5-13
得分:14 
没错啊

粗体文字 憨豆先生[/b]
2009-08-09 21:36



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-282123-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.080994 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved