You are not logged in.

#26 2010-05-13 14:56:18

scio
Member
From: Buffalo, NY
Registered: 2008-08-05
Posts: 366

Re: [Solved] Frustrating C++ error, possibly SDL

toffyrn wrote:

If i didn't do anything wrong (once more) it do compile at least...

http://pastebin.com/gVRLWWKB
http://pastebin.com/ujkW73rB

This code is till returning bools as ints which does work, but is slightly confusing since generally 0 is a good exit condition, but that is false.
Also, you compare to NULL but return 0 for pointers, it's generally nice to be consistent.
Do a quick review of your return types, return values, and use of "true" and "false".

Offline

#27 2010-05-13 22:16:20

GalacticArachnid
Member
Registered: 2009-01-02
Posts: 155
Website

Re: [Solved] Frustrating C++ error, possibly SDL

Thanks toffyrn, thats some really useful stuff there xD

Good call on the main() - i have been looking into the whole object thing and needed to rewrite it, but i figured since im going to have so much of it changed when the ai functions get placed, that i might aswell leave it till last.

Still, it did help me get my head round the use of objects somehow smile

Also, it still wont compile:

monolith.cpp:40: error: expected initializer before 'exitState'
monolith.cpp:42: error: 'temp' was not declared in this scope
monolith.cpp:58: error: expected ';' before 'return'

:C

Another edit: some general cleanign of return types, should be clearer now (I hope)

WAIT, nvm, I fixed it  -> missing some semi-colons... Yeah.. I know..

Last edited by GalacticArachnid (2010-05-13 22:30:33)

Offline

#28 2010-05-13 22:31:53

GalacticArachnid
Member
Registered: 2009-01-02
Posts: 155
Website

Re: [Solved] Frustrating C++ error, possibly SDL

One last thing:

THANK YOU ALL! You have really helped not just with that one set of code, but with my progress to understanding C++ in general big_smile

Offline

#29 2010-05-14 11:37:55

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: [Solved] Frustrating C++ error, possibly SDL

Also, that global screen you've got at the top of your .cpp file could be put inside the class for better encapsulation.  If you need to access it outside the class, you can make a getter method for it.

Offline

Board footer

Powered by FluxBB