Skip to main content
gamedev.net
🔒 Locked

Regarding Class Design

Started by Blutdurst Oct 20, 2003 at 4:00 AM 3 replies 400+ views
Original Post
Blutdurst
Blutdurst
Hello! in my app, I''ve the following classes and files: main.cpp and main.h vmObject.cpp and vmObject.h defining the class vmObject mScript.cpp and mScript.h defining the class mScript vmObject has an instance of mScript, so it''s possible to do sometuing like this: vmObject::runScript(); But since I want the methods of mScript to alter the attributes of its appropriate vmObject, mScripts needs to have a pointer of vmObject as attribure as well. like this:
class vmObject
{
  private:
    mScript *script;
}

class mScript
{
  private:
    vmObject *vmobject;
}
 
Since both classes are in different files, it would be neede to include them mututal, wich isn''t possible (in mscript.h you would #include "vmobject.h" and in vmobject.h you would #include "mscript.h") So, how to solve this? Thanks you
Blutdurst
Blutdurst
ah, thank you

but how could the circ. dependencies be avoided in my case?

dmikesell
dmikesell
quote:
ah, thank you

but how could the circ. dependencies be avoided in my case?


Perhaps an object that holds and instance of both vmObject and vmScript. That way the vmObject and vmScript could still be tied together (in the higher level object) but not have to know about each other. I don''t really understand your problem domain, so I''m just guessing here.

--
Dave Mikesell Software & Consulting

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.