|
-
May 19th, 2009, 08:05 PM
#1
Is this "good" coding style... ?
I'm kind of new to C++, so I'm not sure if this is right. It doesn't really "seem" like all that great of an idea, but it was the best I could think of, and it's working how I want right now.
I'm trying to make a game. However, I would like it to be compatible across multiple operating systems. My solution was to create an class, EngineController, which needs implementation by a given operating system in order to work correctly.
class OSXController, for example, implements EngineController.
Currently, I have it so EngineController has a method StartEngine (protected visibility).
OSXController has a constructor/deconstructor. The constructor initializes libraries (I'm just using SDL for now), and then calls StartEngine. StartEngine keeps running until it breaks out its main while loop, and control transfers back to OSXController. This is where things get dodgy. OSXController calls its own deconstructor (it deletes its own reference). I come from a heavy Java background, so I'm used to things cleaning up after themselves...
Thanks for reading and taking the time to answer.
EDIT: I'm just using static methods now. It works out a lot better, couldn't quite figure out how to use them at the class level before. Anywho, is it still acceptable to use "delete this" within a class?
Last edited by Stachelsk; May 19th, 2009 at 08:26 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|