24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 333  |  回复: 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的回帖

magic7004

金虫 (职业作家)

晕,居然都是拼写错误,搂住也太粗心了。
流氓不可怕,可怕的是流氓有文化,有文化又BH的流氓无敌~~!
3楼2009-10-20 10:54:42
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 3 个回答

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的回帖
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 数一英一271专硕(085401)求调剂,可跨 +7 前行必有光 2026-03-28 8/400 2026-03-28 23:22 by 小木虫tim
[考研] 332求调剂 +4 @MZB382400 2026-03-28 4/200 2026-03-28 21:02 by 唐沐儿
[考研] 295材料工程专硕求调剂 +7 1428151015 2026-03-27 7/350 2026-03-28 19:58 by S240
[考研] 304求调剂 +6 曼殊2266 2026-03-27 6/300 2026-03-28 14:10 by 唐沐儿
[有机交流] 高温高压反应求助 10+4 chibby 2026-03-25 4/200 2026-03-27 21:08 by BT20230424
[考研] 一志愿211院校 344分 东北农业大学生物学学硕,求调剂 +5 丶风雪夜归人丶 2026-03-26 8/400 2026-03-27 19:22 by 丶风雪夜归人丶
[考研] 求调剂 +4 零八# 2026-03-27 4/200 2026-03-27 18:07 by yu221
[考研] 材料与化工085600,总分304,本科有两篇sci参与,求调剂 +10 幸运的酱酱 2026-03-22 12/600 2026-03-27 16:08 by muchong357
[考研] 一志愿北京化工大学 070300 学硕 336分 求调剂 +9 vv迷 2026-03-22 9/450 2026-03-27 15:59 by 不吃魚的貓
[考研] 材料调剂 +8 匹克i 2026-03-23 8/400 2026-03-27 08:11 by hypershenger
[考研] 调剂 +4 柚柚yoyo 2026-03-26 4/200 2026-03-26 20:43 by fmesaito
[考研] 085602 289分求调剂 +8 WWW西西弗斯 2026-03-24 8/400 2026-03-26 16:33 by 不吃魚的貓
[考研] 297求调剂 +6 田洪有 2026-03-26 6/300 2026-03-26 15:55 by 不吃魚的貓
[考研] 一志愿哈工大,085400,320,求调剂 +4 gdlf9999 2026-03-24 4/200 2026-03-25 23:01 by boxking200
[考研] 303求调剂 +6 蓝山月 2026-03-25 6/300 2026-03-25 22:47 by 418490947
[考研] 各位老师您好:本人初试372分 +5 jj涌77 2026-03-25 6/300 2026-03-25 14:15 by mapenggao
[考研] 284求调剂 +15 Zhao anqi 2026-03-22 15/750 2026-03-25 12:51 by wht0531
[考研] 化工专硕求调剂 +3 question挽风 2026-03-24 3/150 2026-03-24 18:48 by jhhcooi
[考研] 材料考研调剂生 +3 黄粱一梦千年 2026-03-24 3/150 2026-03-24 17:00 by barlinike
[考研] 341求调剂(一志愿湖南大学070300) +5 番茄头--- 2026-03-22 6/300 2026-03-23 23:45 by Txy@872106
信息提示
请填处理意见