关于c++的问题(空字符常量)

来源:百度知道 编辑:UC知道 时间:2024/06/02 18:57:38
#include<iostream>

using namespace std;
class AX{
int x;
public:
AX(int xx=0): x(xx) {cout<<"AX constructor."<<endl;}

~AX(){cout<<"AX constructor."<<endl;}

void Output(){ cout<<x<<''; }
int Get() { return x;}

};

class BX: public AX {
int y;
AX z;
public :
BX(int xx=0,int yy=0):AX(xx),y(yy),z(xx+yy) {cout<<"BX constructor."<<endl;}

~BX(){cout<<"BX constructor."<<endl;}

void Output(){
AX::Output();cout<<Get()<<'';
cout<<y<<''<<z.Get()<<endl;
}
};

void main()
{
BX a(5),b(10,20);
a.Output();
b.Output();
}

错误显示:错误 1 error C2137: 空字符常量
2 error C2137: 空字符常量

void Output(){ cout<<x<<''; }
AX::Output();cout<<Get()<<'';
cout<<y<<''<<z.Get()<<endl;
空格可不是啥都没有啊童鞋!
void Output(){ cout<<x<<' '; }
AX::Output();cout<<Get()<<' ';
cout<<y<<' '<<z.Get()<<endl;

#include<iostream>

using namespace std;
class AX{
int x;
public:
AX(int xx=0): x(xx) {cout<<"AX constructor."<<endl;}

~AX(){cout<<"AX constructor."<<endl;}

void Output(){ cout<<x<<" "; }
int Get() { return x;}

};

class BX: public AX {
int y;
AX z;
public :
BX(int xx=0,int yy=0):AX(xx),y(yy),z(xx+yy) {cout<<"BX constructor."<<endl;}

~BX(){cout<<"BX constructor."