• Advertisement
Sign in to follow this  

Class within a Class

This topic is 1757 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys.
 
As far as I understand when working with classes, members should always be kept private and then you should have functions in the public section that manipulates this data. But what if you have a class within a class, for example:

 

class Player
{
  public:
  Inventory backpack;
}

--------------------------
Somewhere in the game
---------------------------
{
  player.inventory.addItem(apple);
}

 

 

Would it still be considered bad practice if the class that is contained within still has it's members encapsulated?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement