Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / 2D game. "Pong" problem...

Author
Message
sLn
13
Years of Service
User Offline
Joined: 1st Jun 2011
Location:
Posted: 2nd Jun 2011 13:53
Hi there.
Im very new to this programming world, and just started making programs. the problem I have got now is a compilor error telling me:

"unresolved external symbol "public: __ thiscall player1::player1(void) refered in fuction "void __cdec1 darkGDK (void)"

usually my compiler errors are easy fix, but this one i dont understand.. Ive been trying to figure this out for some ohurs now, so i wuld really appriciate some help here!

I can post my main.cpp and header files if thats needed. But I mainly just want to know what the error means.

sLn
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 2nd Jun 2011 16:18
It means that you declared a class Player1 and within it you declared a constructor method; but you never defined the constructor in code.



Should do it unless you want your constructor to actually do something...

As a side note though, you should post the relavent code in the future. There may be other root causes to the errors that you're seeing...


JTK
sLn
13
Years of Service
User Offline
Joined: 1st Jun 2011
Location:
Posted: 3rd Jun 2011 13:44
ok i think I understand what you mean, but the code; Player1:layer1() {} is allready in my player1.cpp file. I'll uppload the codes.

Attachments

Login to view attachments
sLn
13
Years of Service
User Offline
Joined: 1st Jun 2011
Location:
Posted: 3rd Jun 2011 13:45
here's my header file:



class player1
{
public:
player1();
~player1();

int movement();
private:
};
sLn
13
Years of Service
User Offline
Joined: 1st Jun 2011
Location:
Posted: 3rd Jun 2011 13:47
and last but not least, the player1.cpp:

JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 3rd Jun 2011 21:09
It would seem then, that your player1.cpp file is not in the project. Make sure you've added it to your project tree and that you don't have it marked as "exclude from build" (property dialog of the file itself).

JTK
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 4th Jun 2011 11:54 Edited at: 4th Jun 2011 12:01
The problem is this line in your main.cpp:



You got the syntax wrong. If a class constructor doesn't have parameters, you don't need brackets. If it does have parameters, then the parameters in brackets must be after the instance name, not the class name. (First is class, second is instance.) Also, the variable (instance) name shouldn't be the same as the class, because you won't be able to distinguish them. (The compiler can, apparently, because it doesn't complain if the syntax is otherwise correct, but you will cause problems for yourself if the names are the same.) Declare the instance like this:



If you plan to re-use this class several times, then it would be better to leave out the number from the class name:

sLn
13
Years of Service
User Offline
Joined: 1st Jun 2011
Location:
Posted: 4th Jun 2011 13:35
Thank you, JTK and Mireben, very much appreiciated. learned a lot. The main problem with the compiler error was; when I make files like cpp and header files, I need to make them within the project. I did not know that. And learned more on classes.

thanks for the help

sLn

Login to post a reply

Server time is: 2024-11-19 10:25:41
Your offset time is: 2024-11-19 10:25:41