Advertisement

int/void function question

Started by March 16, 2000 03:32 PM
1 comment, last by Strife 24 years, 6 months ago
Okay, I know that this question will pretty much sound like a newbie question, but believe me, it''s not. I often get these errors, figure out what''s wrong, and forget what they meant. Can someone help me: --------------------Configuration: GDIPong - Win32 Debug-------------------- Compiling... GDIPMain.cpp c:\windows\desktop\mine\programming stuff\c++ files\gdipong\gdipmain.cpp(201) : error C2556: ''int __thiscall paddle::draw_paddle(struct HDC__ *,int,int)'' : overloaded function differs only by return type from ''void __thiscall paddle::draw_paddle(str uct HDC__ *,int,int)'' c:\windows\desktop\mine\programming stuff\c++ files\gdipong\gdipmain.h(14) : see declaration of ''draw_paddle'' c:\windows\desktop\mine\programming stuff\c++ files\gdipong\gdipmain.cpp(201) : error C2371: ''draw_paddle'' : redefinition; different basic types c:\windows\desktop\mine\programming stuff\c++ files\gdipong\gdipmain.h(14) : see declaration of ''draw_paddle'' c:\windows\desktop\mine\programming stuff\c++ files\gdipong\gdipmain.cpp(241) : error C2556: ''int __thiscall ball::draw_ball(struct HDC__ *,int,int)'' : overloaded function differs only by return type from ''void __thiscall ball::draw_ball(struct HDC_ _ *,int,int)'' c:\windows\desktop\mine\programming stuff\c++ files\gdipong\gdipmain.h(25) : see declaration of ''draw_ball'' c:\windows\desktop\mine\programming stuff\c++ files\gdipong\gdipmain.cpp(241) : error C2371: ''draw_ball'' : redefinition; different basic types c:\windows\desktop\mine\programming stuff\c++ files\gdipong\gdipmain.h(25) : see declaration of ''draw_ball'' Error executing cl.exe. GDIPMain.obj - 4 error(s), 0 warning(s) In case it really matters (or you couldn''t tell), I''m running VC++ 6.0. Thanks for any help. If you code it, they will come... Commander M http://commanderm.8m.com cmndrm@commanderm.8m.com
You need to declare (header file) and define (source file) functions the exact same way, except for the semi-colon at the end of the header file declaration. It looks to me like you might have accidentally left-off the return type in one place.

Header files should have (I'm guessing at the parameters):
class paddle{  //...  void draw_paddle (HDC, int, int);  //...};class ball{  //...  void draw_ball (HDC, int, int);  //...}; 


Source files should have:
void paddle::draw_paddle (HDC dc, int x, int y){  //...}void ball::draw_ball (HDC dc, int x, int y){  //...} 


Hope that helps

Edited by - Stoffel on 3/16/00 3:50:36 PM
Advertisement
Hehehe. Of course. I kinda neglected putting void in front of ball::draw...

Funny... I don''t think I''ve ever done that before with anything, and this is the only time that I''ve gotten errors for that reason. Thanks.

If you code it, they will come...

Commander M
http://commanderm.8m.com
cmndrm@commanderm.8m.com

This topic is closed to new replies.

Advertisement