# 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
---------------------------
{
}


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

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628344
• Total Posts
2982186

• 9
• 24
• 9
• 9
• 13