@fun2code
The objects don't have to be created dynamically using new. |
I said to use new because, I can only get my code to work when I create objects with new. Using the & operator didn't work for me. I am not sure why that is. Your example does not have inheritance, I wonder if that has anything to do with it? I am guessing there is something about the operation of the new operator and the _vptr being inherited?
I hope
L B doesn't mind - we had a lengthy debate last time - I don't wish to rehash the entire debate again. It's all about learning, I guess.
Since posting that code in that thread, I have thought about it a bit more. The problem is that all the objects have to have a PollinateMe function, which isn't ideal, even though they might only be defined once virtually, high up in the inheritance tree for some objects like Animals.
Maybe this could be solved by removing the PollinateMe function from everything except flowers and making use of exceptions. An exception is thrown because the Animal or whatever does not have a PollinateMe function.
It is almost the same though, because we now have an exception handling function. It does sound better form a design point of view.
I have also been thinking about the design of a RPG using the mediator pattern, and I think I have it sorted so that plugins can be used, and the other requirement mentioned by
L B are met. I will investigate the strategy pattern as well.
Hope your respective silly seasons are going well so far. :)