首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

c++入门学习遇到的有关问题

2013-06-26 
c++入门学习遇到的问题#include iostream.hclass xint{int xpublic:xint(int a){xa}void setx(int a)

c++入门学习遇到的问题
#include "iostream.h"
class xint
{
int x;

public:
xint(int a)
{
x=a;
   }
 
   void setx(int a)
   {
   x=a;
   }

   int getx()
   {
   return x;
   }
   void disp()
   {
   cout<<"x="<<x<<'\n';
   }
};
//可能数据成员,可能也有函数等等,许许多多
//备注:一个类的构造函数其实就是对类的数据进行初始化
void main()
{
  xint a(10);
  a.disp();
  a.setx(20);
  int b=a.getx();
  cout<<"b="<<b<<endl;
  a.disp();


}
编译报错:
E:\C++习题集\practice.cpp(61) : error C2018: unknown character '0xa3'
E:\C++习题集\practice.cpp(62) : error C2065: 't' : undeclared identifier
E:\C++习题集\practice.cpp(62) : error C2146: syntax error : missing ';' before identifier 'a'
不知道为什么会出这样的错,请高手指点,感激不尽。。
[解决办法]
xint a(10);
后面不是跟个非法字符吗?

热点排行
Bad Request.