最近在linux下学习c++编程,遇到一个很棘手的问题,发现在linux下与window下studio中编辑代码和编译都有很很大的不同。下面一段简单的代码,发现在linux下报错。源代码和编译后提示的错误如下,
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
unsighed int a(0x2a),b(18);
a&=b;
cout<<a<<endl;
int i(-8),j(2);
i>>=j;
cout<<i<<endl;
i|=~j^j;
cout<<i<<','<<j<<endl;
j&=~j+1;
cout<<i<<','<<j<<endl;
}
编译后提示,
test3.cxx: 在函数‘int main()’中:
test3.cxx:6:4: 错误:‘unsighed’在此作用域中尚未声明
test3.cxx:6:13: 错误:expected ‘;’ before ‘int’
test3.cxx:7:3: 错误:‘a’在此作用域中尚未声明
test3.cxx:7:6: 错误:‘b’在此作用域中尚未声明
有人知道是怎么回事吗?