编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛  
全能 ASP / PHP / ASP.NET 主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付学习型 ASP/PHP/ASP.NET 主机 30元/年
发新话题
打印

请教一个问题,能快点给我帮助吗

请教一个问题,能快点给我帮助吗

#include <iostream.h>
int main()
{
int a;
cout<<"请输入一个数字,按回车结束"<<endl;
cin>> a;
cout<<a<<endl;
return 0;
}

在编译时会出现如下提示:

:\lxc\study\l.c(5) : error C2065: 'cout' : undeclared identifier
d:\lxc\study\l.c(5) : error C2297: '<<' : illegal, right operand has type 'char [27]'
d:\lxc\study\l.c(5) : error C2065: 'endl' : undeclared identifier
d:\lxc\study\l.c(6) : error C2065: 'cin' : undeclared identifier
d:\lxc\study\l.c(6) : warning C4552: '>>' : operator has no effect; expected operator with side-effect
d:\lxc\study\l.c(7) : warning C4552: '<<' : operator has no effect; expected operator with side-effect

TOP

缺少using namespace std;

TOP

这个程序没问题,能用呀

TOP

和编译器有关?。。。

TOP

一楼正解。cout cin 等都是属于命名空间 std。。。

TOP

和编译器有关

TOP

<iostream.h>不需要指定命名空间
而<iostream>要指定命名空间

楼主的问题应该是编译器的问题
不知道痛苦,不知道饥饿,不知道休息,只知道勇往无前...

TOP

1."iostream.h"是基于C语言的头文件,而
   “iostream”是C++的标准格式。
2.两者都可在vc++中使用,但后者必须使用命名空间
   即  using namespace std;已解决重名冲突的问题。
3.你的程序没有错误,可能是编译器的问题
  或着你可以再建一个工程,创建C++文件,在进行编译一次。

TOP

发新话题