标题:using namespace std 这句话有什么功能
取消只看楼主
alickjane
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2005-9-23
 问题点数:0 回复次数:1 
using namespace std 这句话有什么功能
我是一个菜鸟,最近在学习c++的过程中遇到这样的问题 有一个题目:设某次体育比赛的结果有四种可能:胜(win),负(lose),平局(tie),比赛取消(cancle),编写程序顺序输出这四种情况。 源程序为: #include <iostream> using namespace std; enum game_result{WIN,LOST,TIE,CANCEL}; int main() { game_result result; enum game_result omit=CANCEL; int count; for(count=WIN;count<=CANCEL;count++); { result=(game_result)count; if(result==omit) { cout<<"The game was cancelled\n"; } else { cout<<"The game was played"; if(result==WIN) cout<<"and we won!"; if(result==LOST) cout<<"and we lost."; cout<<"\n"; } } return 0; } 如果没有红色的那句程序,编译就不成功,那这句话的作用是什么呢? 而且添加上那句,编译后会出现: The game was played press any key to continue 并没有出现预想的运行结果: The game was played and we won; The game was played and we lost; The game was played The game was cancelled 到底是怎么回事啊?拜请高手指点!
搜索更多相关主题的帖子: std using result namespace count 
2005-09-23 17:05
alickjane
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2005-9-23
得分:0 
赫赫,谢谢拉!
2005-09-23 19:58



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




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

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