紧急求助!!

zhongxiaoying 2003-09-29 10:50:30

//请帮忙看看这个派生啊,椭圆到圆的,有以下错误,地方已标出,--------------------Configuration: 3 - Win32 Debug--------------------
Compiling...
main.cpp
f:\3\figures.h(55) : error C2512: 'ellipse' : no appropriate default constructor available
f:\3\figures.h(55) : error C2614: 'circle' : illegal member initialization: 'ellpise' is not a base or member
f:\3\figures.h(62) : error C2065: 'r' : undeclared identifier
Error executing cl.exe.

class ellipse:public point{
private:
int l1,l2;
public:
ellipse(int i,int j,int k,int l):point(i,j)
{
l1=k;
l2=l;
}
int getl1(void) {return(l1);}
int getl2(void) {return(l2);}
void show()
{
visible=true;
printf("在(%d,%d)位置显示长轴为%d,短轴为%d的椭圆\n",x,y,l1,l2);
}
void hide()
{
visible=false;
printf("在(%d,%d)位置擦除长轴为%d,短轴为%d的椭圆\n",x,y,l1,l2);
}
};


class circle:public ellipse{
private:
void getl1(void) {};
void getl2(void) {};
protected:
int x,y,r;
public:
circle(int x,int y,int r):ellpise(x,y,r,r)
{}//错误都在这里了!
int getradius(void)
{return(ellipse::getl1());}

void show()
{
visible=true;
printf("在(%d,%d)位置显示半径为%d的圆\n",x,y,r);
}
void hide()
{
visible=false;
printf("在(%d,%d)位置擦除半径为%d的圆\n",x,y,r);
}

};
...全文
45 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zoohoo 2003-09-30
  • 打赏
  • 举报
回复
constructor写成这样就可以了,冒号后的写法是对成员变量赋值.
circle(int x,int y,int r){
ellpise::ellpise(x,y,r,r);
}


applecjn 2003-09-29
  • 打赏
  • 举报
回复
学习

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧