c++新手,在linux下编译c++报错

lunar1983 2013-04-03 02:41:27
c++新手,在linux下写一个简单的sample1.cpp文件,编译,报错,求解
代码如下
#include <iostream>
unsing namespace std;

const float PI = 3.1416;
float fCir_L(float);
float fCir_S(float);

main(){

float r,l,s;

cout<<"R = ";
cin>>r;
l = fCir_L(r);
s = fCir_S(r);
cout<<"l = "<<l;
cout<<"\ns = "<<s<<endl;
}

float fCir_L(float x){
float z = -1.0;
if(x >= 0.0)
z = 2*PI*x;
return(z);
}

float fCir_S(float x){
float z = -1.0;
if(x >= 0.0)
z = PI*x*x;
return(z);
}



执行g++ -o sample sample1.cpp 编译后报错:
sample1.cpp:2:1: error: ‘unsing’ does not name a type
sample1.cpp: In function ‘int main()’:
sample1.cpp:12:5: error: ‘cout’ was not declared in this scope
sample1.cpp:13:5: error: ‘cin’ was not declared in this scope
sample1.cpp:17:24: error: ‘endl’ was not declared in this scope

问题:
1,我应该怎样使用命名空间?
2,把“unsing namespace std;”这句去掉,然后在cin,cout前加上std::就好了,不解
...全文
262 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
dynamicer 2013-04-03
  • 打赏
  • 举报
回复
引用 2 楼 FancyMouse 的回复:
using不是unsing
正解
shen_wei 2013-04-03
  • 打赏
  • 举报
回复
引用 4 楼 Roxxette 的回复:
引用 3 楼 shen_wei 的回复:linux 是没有命名空间的。。 int main() { return 0; } 砖家出现啦~~~~
o(︶︿︶)o 唉。。。
lunar1983 2013-04-03
  • 打赏
  • 举报
回复
编译通过,谢谢
Roxxette 2013-04-03
  • 打赏
  • 举报
回复
引用 3 楼 shen_wei 的回复:
linux 是没有命名空间的。。 int main() { return 0; }
砖家出现啦~~~~
shen_wei 2013-04-03
  • 打赏
  • 举报
回复
linux 是没有命名空间的。。 int main() { return 0; }
FancyMouse 2013-04-03
  • 打赏
  • 举报
回复
using不是unsing
SNAKE-SNAKE 2013-04-03
  • 打赏
  • 举报
回复
我也是,不太明白。难道linux下没有命名空间么……坐等大婶解释~

64,282

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧