注册 登录
编程论坛 C++教室

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

lixiuchun717 发布于 2008-06-13 12:39, 916 次点击
#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
7 回复
#2
若是人间2008-06-13 18:14
缺少using namespace std;
#3
若是人间2008-06-13 18:18
这个程序没问题,能用呀
#4
afraid2008-06-13 19:09
和编译器有关?。。。
#5
jayklx2008-06-20 15:03
一楼正解。cout cin 等都是属于命名空间 std。。。
#6
2008-06-20 15:53
和编译器有关
#7
koolism2008-06-20 20:38
<iostream.h>不需要指定命名空间
而<iostream>要指定命名空间

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