24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 526  |  回复: 2

冰雨hust

铁虫 (小有名气)

[求助] 输入输出问题

#include
using namespace std;
template
class compare
{public:
compare(numtype a ,numtype b)
{x=a;y=b;}
numtype max();
numtype min( );
private:
        numtype x;numtype y;
};
template
numtype compare ::max()
{return (x>y)?x:y;}

template
numtype compare ::min()
{return (x


int main()
{ int a;int b;
        compare cmpl(a,b);
        cout<<"please enter two numbers:";
                cin>>a>>b;
cout<<"the max number of the two number is:"< cout<<"the min number of the two number is:"<
return 0;
}
为什么这个程序在编译都通过了,在输入值a,b后(cout<<"the max number of the two number is:"< cout<<"the min number of the two number is:"<
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

libralibra

至尊木虫 (著名写手)

骠骑将军

【答案】应助回帖

感谢参与,应助指数 +1
把compare cmpl(a,b);放在cin>>a>>b之后试试.
在你从终端获得a,b之前,a,b是没有被初始化的任意值
matlab/VB/python/c++/Java写程序请发QQ邮件:790404545@qq.com
2楼2013-03-01 20:46:33
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

haixiawu

金虫 (文坛精英)

【答案】应助回帖

感谢参与,应助指数 +1
逻辑上有错误,compare中的a b不是你输入的a, b
另外,cin >> a >> b; 改成 cin >> a; cin >> b;
3楼2013-03-02 15:21:28
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 冰雨hust 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 283分材料与化工求调剂 +12 罗KAKA 2026-04-02 12/600 2026-04-02 16:50 by guanxin1001
[考研] 085600,材料与化工321分求调剂 +11 大馋小子 2026-03-28 11/550 2026-04-02 15:59 by yunlongyang
[考研] 理学07化学 303求调剂 +16 睿08 2026-03-27 17/850 2026-04-02 13:29 by 七度不信任
[考研] 261求B区调剂 +5 明仔· 2026-04-01 7/350 2026-04-02 11:17 by 邹尉尉
[考研] 土木304求调剂 +6 兔突突突, 2026-03-31 7/350 2026-04-02 09:06 by coolminer
[考研] 085410 一志愿211 22408分数359求调剂 +3 123456789qw 2026-03-31 4/200 2026-04-02 00:06 by 义文wang
[考研] 085601材料工程找调剂 +20 oatmealR 2026-03-29 21/1050 2026-04-01 21:00 by lijunpoly
[考研] 266分求材料化工冶金矿业等专业的调剂 +7 哇呼哼呼哼 2026-03-26 7/350 2026-04-01 20:47 by cqupH
[考研] 材料与化工(0856)304求B区调剂 +8 邱gl 2026-03-30 16/800 2026-04-01 17:58 by 邱gl
[考研] 一志愿 南京航空航天大学 ,080500材料科学与工程学硕 +7 @taotao 2026-03-30 7/350 2026-04-01 14:30 by chenqifeng666
[考研] 085410人工智能 初试316分 求调剂 +3 残星拂曙 2026-03-31 3/150 2026-04-01 11:09 by 小熊raider
[考研] 318求调剂 +8 七忆77 2026-04-01 8/400 2026-04-01 10:37 by Jaylen.
[考研] 289求调剂 +3 Acesczlo 2026-03-29 4/200 2026-03-31 14:48 by 热情沙漠
[考研] 本科211生物医学工程085409求调剂339分 +7 里子木yy 2026-03-29 7/350 2026-03-31 14:35 by fmesaito
[考研] 313求调剂 +6 卖个关子吧 2026-03-31 6/300 2026-03-31 10:58 by Jaylen.
[考研] 08工科,295,接受跨专业调剂 +6 lmnlzy 2026-03-30 6/300 2026-03-31 10:04 by cal0306
[考研] 吉大生物学326分求调剂 +3 sunnyupup 2026-03-31 3/150 2026-03-31 09:28 by longlotian
[考研] 一志愿南开大学0710生物学359求调剂 +5 兔兔兔111223314 2026-03-29 7/350 2026-03-30 18:29 by 兔兔兔111223314
[考研] 复试调剂 +3 raojunqi0129 2026-03-28 3/150 2026-03-28 15:27 by 落睿可思
[考研] 315调剂 +4 0860求调剂 2026-03-26 5/250 2026-03-27 11:23 by wangjy2002
信息提示
请填处理意见