Hi, in the program I am writing I have placed several objects of the same class in an array. When I try and access a public method of one of the objects from a different .cpp file, it displays several error messages even though the object array is global. I have abridged versions of the files below. Any ideas?
Code:// main .cpp file #include <iostream> #include "Room.h" using namespace std; CRoom Rooms[14]={1,2,3,4,5,6,7,8,9,10,11,12,13,14}; void main() { title(); Rooms[1].set_door(0,2,0,1); Rooms[2].set_door(7,1,9,11); Rooms[3].set_door(9,0,0,10); Rooms[4].set_door(0,10,0,0); // ...etc etc // another .cpp file #include <iostream> #include "Player.h" using namespace std; CPlayer::~CPlayer() { } void CPlayer::move(int direction) { Rooms[1].set_door(1,2,3,4); // errors occurs when this line is include e.g. // 'Rooms' : undeclared identifier // subscript requires array or pointer type // left of '.set_door' must have class/struct/union type }



LinkBack URL
About LinkBacks


