I've been looking through class and friends and similar c++ arrangements to share data, and cannot find how to program levels of share.

No players can know what the other players have in their gold-sack or their arrow quiver, basically.

Only a few players can know such things.

Basically, how do I set up security levels of data access?


You will find that we generally cannot expect to use C++'s or any language's constructs to directly model our domain/game.  For example, languages offer inheritance, and friends, but these unlikely translate into the modeling features needed for any specific domain/game.  The language constructs, as a set, are designed for modeling of the implementation/code/abstractions for a domain — rather than for modeling the domain itself directly.

Instead, we use the language-offered constructs to create abstractions by coding (say, creating classes and instances of them), and those abstractions represent & perform the domain/game concepts, perhaps such as those involving players, levels, access, and denial.

For example, at some point, you may want to ask whether a player has access to an object — you can create abstractions that allow posing and answering questions like this, maybe in the form of a method that returns a value approving or disapproving of access.

The entities and their configuration form the basis of your domain model.  The domain model defines entities of information, their interconnections, and adds to that the ability to pose questions and get answers or accomplish other behaviors.  The same domain model can be created using abstractions in virtually any language despite the vast differences in their basic constructs.

So, it is an indirect process.  We use language constructs to create domain entities, relationships, and behaviors that offer us queries and commands relevant to the domain/game and its concepts and relationships.

  • In that case, "class" is not the one to use for the four levels of privacy desired (private, inclusive, exclusive, public). It seems like I need a few more lines of code than "class" needs. Hacktime! – Dalek Lucifer Dec 31 '18 at 0:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.