Sign in to follow this  
PragmaOnce

Class within a Class

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this