Hello
I have another programming design question..
Lets say I have 3 classes like below:
Code:class parser { }; class user { }; class session { public: std::list<user> m_list; };
Session class is a 'main class' where most of the work is being done (in loop/s)..
It has a list of user objects, where each user needs access to 1 particular parser object (parser class).
I dont want each user to have its own parser object since that would be unneccessary..
I wonder what is the best approach to make class user (user objects) be able to access data in one parser object?
I know most of you would just pass parser object's reference to user class constructor, and then access data this way.
Is there any better way/design pattern to achieve that?
Maybe I shouldn't bother because this might be the best/easiest way?
Or is there more 'professional' way?
Another thing I'm unsure about..
In case passing reference of parser object to user objects is the best way, where would you guys define parser object?
Does this seem okay:
Thanks for helpCode:class session { public: std::list<user> m_list; parser m_parser; };
Regards