http://cubeupload.com/files/ea1a29uml01.jpg
The UML diagram in the image above shows everything related to my problem. As you can see, there are two classes, "App" and "Item".
On runtime one object(let's call it "x") of the class "App" is created, which in turn creates several objects of the class "Item". The items, however, don't even know that x exists, because it's a one-way relationship.
x handles things like the player score and calls the member function "OnTouchedByPlayer" of an item when the player touches it.
The item that was touched should then add points to the player's score, however this is not possible since the item doesn't know about x.
Of course I could pass x by reference to "OnTouchedByPlayer", but that doesn't seem like a good solution.
I'm not very experienced with C++, so I'm kind of stuck, and I'd like to know how this is usually done.
Oh, and another question:
There's only one instance/object(Is there a difference?) of "App" created throughout the runtime of the application, and it exists as long as the application is running. Doesn't that mean it would be more reasonable to use a namespace instead of a class?
That would essentially solve my first problem, but a namespace doesn't have things like private and public members, so I'm not sure if that'd be a good idea.
Thanks in advance.