Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COThank you very much for your answer. I'll add an arrow, collisions (only between players) and support for 2-3 players (Human and Computer). I just always believed It is really forbidden to let a class like Player to know about its Board. That's one point I can use to deduce for a lot of other Projects where I tried to avoid passing ref of a data member or this in the sake of OOP rules.
      singulars
    2. CO@SyndicatorBBB: this is what I was afraid of :-) Do not "deduce a lot". The fact that a class should not know about the implementation details of another class is a valid principle and it is called *Information Hiding*. You don't want to give that up. However, here it seems to me that the board is a *visible* element of the `GameEngine` class. The pointer is declared as private because you don't want other classes to overwrite that *pointer*, making `GameEngine` point to *another* board. But the *pointed object* itself is supposed to be shared, I guess. [continues...]
      singulars
    3. CO@SyndicatorBBB: [...] So you are not really passing a private member of the class, but rather you are passing an object to which the class is associated through a private member (in your case, a raw pointer, but again, use smart pointers instead). Now if you were giving `Player` a *reference* to that pointer, meaning that you are actually passing *the association itself* and not only the associated object, then you would be breaking the encapsulation principle. So indeed passing a reference or a pointer **to** a member variable is usually not OK. But in this case you are not doing that.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload