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 / My Compiler Kicked Me In the Face.

Author
Message
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 22nd May 2009 22:33
To put it short, arrays do not do the best job in my situation, tried to switch one aspect of my game over to classes, don't work, get these errors when I try to compile

fat errors:

yeah those were like the compiller kicking me in the face.

Here is the class:


And here are the various areas i'm trying to use it:




I've read multiple tutorials on classes, I cant even use '.''s to access my variables.

I just dont get it...

I <3 C++ & Dark GDK 4 2 maek mai gamezorz! =D
ABXG
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Canada
Posted: 22nd May 2009 22:54
You have to initialize values of the class in the constructor, you can't just define and initialize at the same time in a class. Example:



In your main program you would call something like this:



------------------------------------
Currently 1500+ lines of code into an "over-the-shoulder" action RPG with combat based on rag-doll physics.
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 22nd May 2009 23:06 Edited at: 22nd May 2009 23:07
It would be retrun before myOutput... correct?


I <3 C++ & Dark GDK 4 2 maek mai gamezorz! =D
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 22nd May 2009 23:25
Ah yes I think it's working! Thank you so much ABXG now I have a few more hours of coding before I run into more things hehe

I <3 C++ & Dark GDK 4 2 maek mai gamezorz! =D
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 22nd May 2009 23:52
Oh no..


New class based off what ABXG taught me:


being used here:



wtfpwnt myself?

I <3 C++ & Dark GDK 4 2 maek mai gamezorz! =D
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 23rd May 2009 00:30 Edited at: 23rd May 2009 00:33
Quote: "LP->CanAttack
LP->attack"


CanAttack and attack are private members of the class. In order to access them you need to use a public member function to get/set the values. Otherwise, you can set the data to public.

I think you may be trying to access the functions Can_Attack and Attack. If so, that's not what you're actually requesting.

You may have the same problem with over variables in the class.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 23rd May 2009 00:39
I made all the variables public

but still:


I'm just trying to create a simple player class to be the object for my player and hold all its variables and related functions.. I think i'm missing something about classes because what i'm doing, to me, looks logically correct. -_-*

I <3 C++ & Dark GDK 4 2 maek mai gamezorz! =D
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 23rd May 2009 00:48
You're trying to call the integer and bool as if they were functions. Are you trying to get/set these variables or are you trying to call the functions Can_Attack and Attack? You're showing

LP->attack (second)

That's a function call. attach is not a fucntion. It's a variable.

I'm not sure what the problem is with the identifier "Initialize". I'm guessing that you have something with that identifier in another .h file and would have to look there to find the problem.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 23rd May 2009 00:52
I'm trying to call the functions, Attack is a function attack is a variable capital difference on the a's

The identifier is unique...

I <3 C++ & Dark GDK 4 2 maek mai gamezorz! =D
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 23rd May 2009 00:59


Change your code to the above.

Do you have a header file called "declarations.h"? Look there for Initialize

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 23rd May 2009 01:02 Edited at: 23rd May 2009 01:04
My class is in the declarations.h file, right after the class is my initialize

This is the only error that comes up now,



I <3 C++ & Dark GDK 4 2 maek mai gamezorz! =D
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 23rd May 2009 02:07
And what's at line # 107 in declarations.h?

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 23rd May 2009 02:10 Edited at: 23rd May 2009 02:15
tplayer *LP = new Initialize;

okay.. but.. if.. I'll try and move it elsewhere. I thought that was where it was supposed to be..

Edit: anywhere else I put it either comes up with the same error or does not work alltogether. -_-*

I <3 C++ & Dark GDK 4 2 maek mai gamezorz! =D
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 23rd May 2009 02:15
Do you have a class called Initialize?

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 23rd May 2009 02:16
here:


I <3 C++ & Dark GDK 4 2 maek mai gamezorz! =D
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 23rd May 2009 02:23
Intialize isn't a class, it's a class member. What you want to do is

tplayer *LP = new tplayer; //
LP->Initialize();

This says

declare a pointer to type tplayer called LP, create a new tplayer object somewhere in the system and return the address of that object so I can assign it to my pointer.

The next step says to use the pointer to the object to run the Initialize() function in that class.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 23rd May 2009 02:32
ack, thank you very much =]

It worked! =DD

I <3 C++ & Dark GDK 4 2 maek mai gamezorz! =D

Login to post a reply

Server time is: 2024-11-25 10:52:07
Your offset time is: 2024-11-25 10:52:07