24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 334  |  回复: 2
当前主题已经存档。

zhanglei22

银虫 (小有名气)

[交流] 【求助】帮我看下vc++ 6.0的这个类继承哪里出问题了?【已完结】

#include


class Box
{
        int width,height;
public:
        void SetWith(int w)
        {
                width=w;
        }
        void SetHeight(int h)
        {
                height=h;
        }
        int GetWidth(){return width;}
        int GetHeight(){return height;}
};

class ColoredBox:public Box
{
        int color;
public:
        voidSetColor(int c)
        {
                color=c;
        }
        int GetColor(){return color;}
};

main(void)
{
        ColoredBox cbox;
        cbox.SetColor(3);
        cbox.SetWidth(150);
        cbox.SetHeight(100);

        cout<<"cbox:"<         cout<<"color:"<         cout<<"width:"<         cout<<"Height:"< }


--Configuration: 1019 - Win32 Debug--------------------
Compiling...
10191.cpp
c:\program files\microsoft visual studio\myprojects\1019\10191.cpp(27) : warning C4183: 'voidSetColor': member function definition looks like a ctor, but name does not match enclosing class
c:\program files\microsoft visual studio\myprojects\1019\10191.cpp(34) : error C2039: 'SetColor' : is not a member of 'ColoredBox'
        c:\program files\microsoft visual studio\myprojects\1019\10191.cpp(20) : see declaration of 'ColoredBox'
c:\program files\microsoft visual studio\myprojects\1019\10191.cpp(35) : error C2039: 'SetWidth' : is not a member of 'ColoredBox'
        c:\program files\microsoft visual studio\myprojects\1019\10191.cpp(20) : see declaration of 'ColoredBox'
c:\program files\microsoft visual studio\myprojects\1019\10191.cpp(42) : warning C4508: 'main' : function should return a value; 'void' return type assumed
执行 cl.exe 时出错.

1019.exe - 1 error(s), 0 warning(s)

[ Last edited by 余泽成 on 2010-1-28 at 10:45 ]
回复此楼

» 猜你喜欢

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

senlia

木虫 (小有名气)

★ ★ ★
nono2009(金币+2,VIP+0):谢谢专家! 10-19 21:36
zhanglei22(金币+1,VIP+0): 10-20 16:29
class ColoredBox里面 voidSetColor(int c)的void 后面没打空格
class Box里面 SetWith应该是SetWidth
另外 main(void)是不是该写成void main()
这些都是表面的错误 看你贴出来的错误提示得到的 至于还有没有别的错误 我不清楚 因为我这里没有能用的编译软件 你先改改试试吧 不行再和大家讨论讨论

[ Last edited by senlia on 2009-10-19 at 21:26 ]
书到用时方恨少, 天涯何处无芳草.
2楼2009-10-19 21:23:36
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

magic7004

金虫 (职业作家)

晕,居然都是拼写错误,搂住也太粗心了。
流氓不可怕,可怕的是流氓有文化,有文化又BH的流氓无敌~~!
3楼2009-10-20 10:54:42
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 zhanglei22 的主题更新
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 300求调剂,材料科学英一数二 +8 leaflight 2026-03-24 8/400 2026-03-29 01:31 by fmesaito
[考研] 一志愿211 初试270分 求调剂 +8 谷雨上岸 2026-03-23 9/450 2026-03-29 01:00 by 我是小康
[考研] 348求调剂 +3 小懒虫不懒了 2026-03-28 3/150 2026-03-29 00:39 by 544594351
[考研] 356求调剂 +3 gysy?s?a 2026-03-28 3/150 2026-03-29 00:33 by 544594351
[考研] 一志愿武汉理工,总分321,英一数二,求老师收留。 +7 nnnnnnn5 2026-03-25 7/350 2026-03-29 00:32 by 我是小康
[考研] 本科双非材料,跨考一志愿华电085801电气,283求调剂,任何专业都可以 +6 芝士雪baoo 2026-03-28 7/350 2026-03-28 21:40 by zhq0425
[考研] 322求调剂 +7 宋明欣 2026-03-27 7/350 2026-03-28 21:27 by sanrepian
[考研] 求调剂 +7 争取九点睡 2026-03-28 8/400 2026-03-28 21:07 by 争取九点睡
[考研] 本科新能源科学与工程,一志愿华理能动285求调剂 +3 AZMK 2026-03-27 5/250 2026-03-28 16:19 by xxxsssccc
[考研] 275求调剂 +10 Micky11223 2026-03-25 14/700 2026-03-28 15:48 by Micky11223
[考研] 复试调剂 +3 raojunqi0129 2026-03-28 3/150 2026-03-28 15:27 by 落睿可思
[考研] 0703一志愿9,初试成绩:338,四六级已过,有科研经历,求调剂! +4 Zuhui0306 2026-03-25 4/200 2026-03-28 13:07 by 唐沐儿
[考研] 材料与化工(0856)304求B区调剂 +8 邱gl 2026-03-27 8/400 2026-03-28 12:42 by 唐沐儿
[考研] 0703化学求调剂,各位老师看看我!!! +5 祁祺祺 2026-03-25 5/250 2026-03-27 21:44 by 东方猪猪
[考研] 266分求材料化工冶金矿业等专业的调剂 +4 哇呼哼呼哼 2026-03-26 4/200 2026-03-27 17:02 by zhyzzh
[考研] 一志愿郑大085600,310分求调剂 +5 李潇可 2026-03-26 5/250 2026-03-27 11:14 by 不吃魚的貓
[考研] 一志愿吉大071010,316分求调剂 +3 xgbiknn 2026-03-27 3/150 2026-03-27 10:36 by guoweigw
[考研] 0703化学338求调剂! +6 Zuhui0306 2026-03-26 7/350 2026-03-27 10:35 by shangxh
[考研] 材料专硕找调剂 +5 哈哈哈吼吼吼哈 2026-03-23 5/250 2026-03-24 19:07 by 了了了了。。
[考研] 一志愿南航材料专317分求调剂 +5 炸呀炸呀炸薯条 2026-03-23 5/250 2026-03-24 16:52 by 星空星月
信息提示
请填处理意见