Welcome to Egypt Forums Mark forums read | Egypt Main Page
Egypt Forums
Arabic Movies



Programming Languages A Place for windows applications programs and programmers .

Programming Languages Thread, Class design C++ in Programming , WebDesign & Development; I'm having trouble coming up with a good design for a project I'm doing. The below works, but I feel ...

Short Link: http://forum.egypt.com/enforum/showthread.php?t=18846


Reply
 
 
Senior Member

Reply With Quote
 
Join Date: Dec 2008
Posts: 18,122
19-01-2009, 04:00 PM
 
I'm having trouble coming up with a good design for a project I'm doing. The below works, but I feel it's messy at best to have a member class take the 'this' pointer from it's owner. Any tips on structure would be great. What I'm trying to...

I'm having trouble coming up with a good design for a project I'm doing. The below works, but I feel it's messy at best to have a member class take the 'this' pointer from it's owner. Any tips on structure would be great.



What I'm trying to do:

In essence, it's an automata system. Each entity is in a state and that state determines how it updates. Entities call a different update function that changes during runtime.


How I've implemented it:

Code:
class entity
{
public:
Update() { state->update(this); }
int getDataForUpdate();

private
State* state;

//other stuff

};

class State
{
public:
Update(entity& toUpdate) { return DoStuffForUpdate( toUpdate->getDataForUpdate())}


// other stuff
};
 
 
 
Reply

Programming Languages Thread, Class design C++ in Programming , WebDesign & Development; I'm having trouble coming up with a good design for a project I'm doing. The below works, but I feel ...

Short Link: http://forum.egypt.com/enforum/showthread.php?t=18846


Bookmarks

Tags
class, design


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump