这段代码为什么就是编译不过?
#include <iostream>using namespace std;
class demo
{
public:
demo(){x=0;cout<<"demo的默认构造函数"<<x<<endl;}
demo(int i){x=i;cout<<"demo的带一个参数的构造函数"<<x<<endl";}
~demo(){cout<<"demo的默认析构函数"<<x<<endl;}
int get(){return x;}
void set(int i){x=i;}
private:
int x;
};
class rectangle
{
public:
rectangle(){x=1000;cout<<"rectangle的默认构造函数"<<x<<endl;}
rectangle(int i,int j,int k):x(i),width(j),length(k)
{cout<<"rectangle的带3个参数的构造函数"<<"长方形b的面积为:"<<width.get()*length.get()<<endl;}
~rectangle(){cout<<"rectangle的默认析构函数"<<x<<endl;}
int area(){return length.get()*width.get();}
private:
int x;
demo length;
demo width;
};
int main()
{
rectangle a(100,200,300);
return 0;
}
它出现的错误是:
error C2001: newline in constant
error C2079: 'length' uses undefined class 'demo'
fatal error C1004: unexpected end of file found
完全看不懂什么意思,请高手赐教