I am reading through a framework for a game, and it has a Door struct inside the Room class as follows:
#include <vector>
class Room{
public:
struct Door{
unsigned name;
unsigned orientation;
Room* room1;
Room* room2;
};
std::vector<Door*> adjacent;
};
What is the purpose of defining a struct inside of a class? And, does it make a difference what access modifier that the struct is defined with?
It’s just a nested type.
If
Doorwas declaredprivatethen trying to declare a variable of typeRoom::Dooroutside this class will give an error.