| 查看: 293 | 回复: 2 | |||
| 当前主题已经存档。 | |||
[交流]
【求助】帮我看下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:"< --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 ] |
» 猜你喜欢
磺酰氟产物,毕不了业了!
已经有8人回复
求助:我三月中下旬出站,青基依托单位怎么办?
已经有10人回复
26申博(荧光探针方向,有机合成)
已经有4人回复
要不要辞职读博?
已经有3人回复
论文终于录用啦!满足毕业条件了
已经有26人回复
2026年机械制造与材料应用国际会议 (ICMMMA 2026)
已经有4人回复
Cas 72-43-5需要30g,定制合成,能接单的留言
已经有8人回复
北京211副教授,35岁,想重新出发,去国外做博后,怎么样?
已经有8人回复
自荐读博
已经有3人回复
不自信的我
已经有5人回复
senlia
木虫 (小有名气)
- 应助: 2 (幼儿园)
- 贵宾: 3.521
- 金币: 2178.1
- 红花: 1
- 帖子: 223
- 在线: 6.7小时
- 虫号: 849005
- 注册: 2009-09-16
- 性别: GG
- 专业: 计算数学与科学工程计算
★ ★ ★
nono2009(金币+2,VIP+0):谢谢专家! 10-19 21:36
zhanglei22(金币+1,VIP+0): 10-20 16:29
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

3楼2009-10-20 10:54:42












回复此楼