热血燃向古风歌:C++编译错误 unexpected end of file found

来源:百度文库 编辑:高考问答 时间:2024/05/07 15:30:24
#include <iostream.h>
#include <math.h>
class Cpoint
{
public:
Cpoint(int a,int b)
{
x=a;y=b;
}
int getx()
{
return x;
}
int gety()
{
return y;
}
private:
int x,y;
};

class Cline:public Cpoint
{
public:
Cline(int a,int b,int c,int d):Cpoint(a,b)
{x=c;y=d;}
double length()
{
return(sqrt((getx()-x)*(getx()-x)+(gety()-y)*(gety()-y)));
}

show()
{
l1=length();
cout<<"第一条直线长"<<l1<<endl;
}
private:
int x,y;double l1;
};
class Crect :public Cline
{
public:
Crect(int a,int b,int c,int d,int e,int f):Cline(a,b,c,d)
{
x=e;y=f;

}
show2()
{
l2=length();
cout<<"第二条直线长"<<l2<<endl;
}

getarea()
{
cout<< l1*l2<<endl;
}
getzhouc()
{
cout<< 2*(l1+l2)<<endl;
}

void main()
{

Crect xxx(0,2,2,0,2,2);
xxx.show();
xxx.show1();
xxx.gearea();
xxx.getzhouc();
}

class Crect :public Cline
{
public:
Crect(int a,int b,int c,int d,int e,int f):Cline(a,b,c,d)
{
x=e;y=f;

}
show2()
{
l2=length();
cout<<"第二条直线长"<<l2<<endl;
}

getarea()
{
cout<< l1*l2<<endl;
}
getzhouc()
{
cout<< 2*(l1+l2)<<endl;
}

////////////////////////////在这里加上下面这个

};

出现你那个错误就像楼上的指出是少了};
但你的程序还有错 自己检查一下 怎么能把属性直接赋给继承来的私有成员呢

呵呵,在头上加上#include "stdafx.h"再试试,或者在工程属性中选择不要预编译

对!!是这样的。