First, I have limited experience with object oriented design and programming. So, I have some comments and questions for you, but take them in the light of my limited experience. Hopefully, you can teach me something.
You asked:
How to properly return an array of objects in c++ and use it main? |
In the normal case, why not create the objects in main and pass them as parameters to the methods which need to know about the objects.
You have a class named
Observable
. Observable is an adjective. I would expect the class name to be a noun. So looking at the other code, I would expect the class to be named Observers and objects of the class would be individual observers. What am I not seeing?
What can an Observe do? You show methods addObserver() and removeObserver(). Is not this the purpose of the constructor and destructor, respectively? What actions can an observer take or be subject to?
Similarly you have a class named
CritterDisplay
. I would expect that you would have a class named Critter which would include a method named Display. What am I not seeing?
You have a class named
CritterModel
. Would a better name be CritterGame?
Can an individual critter be displayed? Or does one display the entire CritterModel or CritterGame?
This program seems to be based on time. How are you going to model time? Should current time be a characteristic of an object from the class CritterModel or class CritterGame? How does time tick?
Does a CritterModel or CritterGame need to keep track of one or more Critters and Observers? Should the CritterModel or CritterGame be tracking the creation and removal of these.