Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Strife

int/void function question

This topic is 6818 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!