【C++学习之路】VS2015中cout、cin未声明的标识符错误的处理
2016-07-28 15:21
986 查看
如下,如果使用老的输入输出流进行编译时就会发现报错
示例代码
[cpp] view
plain copy
print?
#include "stdafx.h"
#include <iostream.h>
int main(int argc,char* argv[])
{
int a, b, sum;
cout << "Please input a:" << endl;
cin >> a;
cout << "Please input b:" << endl;
cin >> b;
sum = a + b;
cout << "The sum is:" << sum << endl;
return 0;
}
编译后就会发现在报“cout”: 未声明的标识符类似的错误
此时做如下修改即可
[cpp] view
plain copy
print?
#include "stdafx.h"
#include <iostream>
using namespace std;
int main(int argc,char* argv[])
{
int a, b, sum;
cout << "Please input a:" << endl;
cin >> a;
cout << "Please input b:" << endl;
cin >> b;
sum = a + b;
cout << "The sum is:" << sum << endl;
return 0;
}
1、将#include <iostream.h>非标准输入输出流修改为#include <iostream>的标准输入输出流
2、在开头添加引号内的内容“using namespace std;"以使用标准名称空间
做好以上两个修改后,编译可通过
示例代码
[cpp] view
plain copy
print?
#include "stdafx.h"
#include <iostream.h>
int main(int argc,char* argv[])
{
int a, b, sum;
cout << "Please input a:" << endl;
cin >> a;
cout << "Please input b:" << endl;
cin >> b;
sum = a + b;
cout << "The sum is:" << sum << endl;
return 0;
}
编译后就会发现在报“cout”: 未声明的标识符类似的错误
此时做如下修改即可
[cpp] view
plain copy
print?
#include "stdafx.h"
#include <iostream>
using namespace std;
int main(int argc,char* argv[])
{
int a, b, sum;
cout << "Please input a:" << endl;
cin >> a;
cout << "Please input b:" << endl;
cin >> b;
sum = a + b;
cout << "The sum is:" << sum << endl;
return 0;
}
1、将#include <iostream.h>非标准输入输出流修改为#include <iostream>的标准输入输出流
2、在开头添加引号内的内容“using namespace std;"以使用标准名称空间
做好以上两个修改后,编译可通过
相关文章推荐
- C# 调用C++ SDK/API的问题总结
- c++中的继承的讲解
- C++ map用法
- 5-42 整型关键字的散列映射
- 继承下的几个概念的区别
- c++List用法
- 基于C++浮点数(float、double)类型数据比较与转换的详解
- windows7下makefile例程
- libevent入门教程:Echo Server based on libevent
- HDU 1010 Tempter of the Bone(DFS + 剪枝)
- C语言中函数参数入栈的顺序
- C语言数值表示和计算
- C++代码规范之命名规则
- codeblocks安装boost库
- C语言main函数参数
- C++学习 - 模板函数变长参数
- POJ 2586 Y2K Accounting Bug(贪心)
- C++ 应用程序无法正常启动(0xc000007b)。请单击 "确定" 关闭应用程序。
- C++中string类型用于send函数-socket发送zifu
- c++11 之可变参数模板