I am trying to define two structs inside a header file that both of them contain each other as objects. More specifically:
typedef struct Dweller {
int id;
int age;
std::string name, lastname;
Room room;
float foodconsume;
float waterconsume;
};
typedef struct Room {
int id;
int WIDTH = 400;
int HEIGHT = 100;
std::vector<Dweller> dwellers;
float energyconsumed;
int property;
int floor, roomno;
};
But as you might have noticed, this is an issue because the Dweller
doesn't know what Room
is at that point of the code. I am using C++, and I am aware that I can make them classes, then forward declare them. But I want to know if I can achieve something like this without getting them into classes. I also want to use them seperately, so I don't want one of them getting declared inside other one.