I have an object Room and each Room has an array of 4 references to other rooms
header file:
namespace test
{
class Room
{
public:
Room* references[4];
void Connect(Room roomReference) const;
}
}
and in my cpp file, I am attempting to attach that reference by inserting the pointer of the room to a specific index in references. However, I get the following compiler error "Cannot assign to readonly type Room* const." But when I create a local variable of the same type and insert into there, it works.
void Room::Connect(Room roomReference) const
{
Room* roomReferenceItem = &roomReference;
Room* foos[4];
// This works
foos[2] = roomReferenceItem;
// This does not
this->references[2] = roomReferenceItem;
}
I am not sure if there is some misunderstanding I am having with global arrays in C++