setting up and also accessing classes

This is a discussion on setting up and also accessing classes within the C++ Programming forums, part of the General Programming Boards category; Hi, I have brought a book & also I have read about 2 -3 tutorials, but still don't understand about ...

setting up and also accessing classes

Hi, I have brought a book & also I have read about 2 -3 tutorials, but still don't understand about cllasses. What I need to know is how to use them, most of these books only tell you the basic stuff. If you had a player object and a map object, which one would hold the players position? Also how would the player object and Map object communicate, If the player moves how would the Map update it's self on where the player is.

Well that could be done several ways. First of all, you'd probably store the player's location in the Player object. To communicate movement with a Map object, you'd need a function. I guess you could put that in either class, but I think putting it in Player would be best.

What data/methods you put into what classes is highly subjective. It depends on the nature of the data, the classes, and what the programmer has in mind as far as design goals for each class. In general, however, avoid circular dependencies between classes (either player should know about map or vice-versa, but if possible, not both).

Thor's self help tip:
Maybe a neighbor is tossing leaf clippings on your lawn, looking at your woman, or harboring desires regarding your longboat. You enslave his children, set his house on fire. He shall not bother you again.