关于using namespace std



//#include "stdafx.h"    /*   stdafx.h应是VC里的东东*/

#include<iostream>
//using namespace std;
int max(int i, int j)
{                        /*定义max()函数*/
    if (i>=j) return i;
    else      return j;
}

int main(void){                             /*定义main()函数*/
  std::cout<<"输入i,j:";                       //显示提示信息
   int i, j;                                //说明变量
   std::cin>>i>>j;                               //从键盘上输入变量的值                                                                                                  
   std::cout<<"最大数是:"<<max(i, j)<<'\n';     //输出提示信息和结果
   return 0;
}


我在学第一个程序时
在C++.NET中
#include "stdafx.h"
#include <iostream>
using namespace std;
void main(void)
{
cout<<"hello!";
}
能运行
可是在C++6.0中
不要using namespace std;这一句也行而C++.NET就不行,为什么?
还有就是
为什么书上没有#include "stdafx.h"这一句,而我要输入这一句才能运行成功,不然就说“fatal error C1010: 在查找预编译头指令时遇到意外的文件结尾”
stdafx.h是什么?


关于using namespace std

http://bbs.csdn.net/topics/70128018

http://www.chinaitlab.com/c/cc/basic/200906/786664.html

http://blog.chinaunix.net/uid-21411227-id-1826642.html

http://www.cnblogs.com/uniqueliu/archive/2011/07/10/2102238.html

http://www.zhihu.com/question/26911239




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值