Jump to content
  • Advertisement
Sign in to follow this  
PragmaOnce

Class within a Class

This topic is 1881 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
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!