Hello
I have a question regarding a concept of object oriented programming. This is probably going to be an easy one to answer for you guys.
Lets say I have 2 classes : ChessGame and Pawn
Now if I create an instance of Pawn inside the ChessGame , I can then access methods/variables of Pawn using getters/setters and public methods because I have created and
initialized the instances of Pawn from within ChessGame , so I can pass variables from ChessGame to the public methods in Pawn and then use them in the methods .That makes sense.
But what If I wanted to access variables of an instance of ChessGame from the class Pawn ? It doesn't allow me to do that . It doesn't recognise the instance of ChessGame because it was
initialised from another class. So can I access Variables of a class A from class B without having initialised A in B? Or is it conceptually done so you can't do that?
I would appreciate any explanation.
Thanks in advance