扩展类的构造函数

dbserver 2003-07-13 11:53:17
基类:
class test
{
public:
test(int,int);
private:
int num;
int price
};
test(int a,int b)
{
test::num=a;test::price=b;
}
扩展类:
class stu:public test
{
public:
stu(int,int);
};
扩展类构造函数的实现:
stu::stu(int x,int y ):test(x,y)
{
.....//是不是有错尼?
}
现new 一个stu对象时:
stu * s=new stu(2,3)//这句话为什么有错呢?是不是扩展类的构造函数写错了呢?
...全文
53 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
mickwang 2003-07-13
  • 打赏
  • 举报
回复
stu::stu(int x,int y ):test(x,y)

不要:test(x,y)还有有错吗?
hahahawk 2003-07-13
  • 打赏
  • 举报
回复
搂主怎么不把最关键的一段代码贴出来?
stu::stu(int x,int y ):test(x,y)
{
.....//是不是有错尼?
}
这里面是什么?是不是操作了num和price?

7,540

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 VC.NET
社区管理员
  • VC.NET社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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