Ah, I see. I didn't realize you could initialize an object and push it into a vector at the same time. I decided to use classes; however, how would I refer to individual variables in that class that are private?
I'm using this:
Code:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class room {
private:
int roomID;
string roomDesc;
public:
room(int, string);
~room();
void descOut();
};
room::room(int roomID, string roomDesc) {
roomID = roomID;
roomDesc = roomDesc;
}
room::~room() {
}
void room::descOut() {
cout << roomDesc;
}
void valueSet(vector<room>& roomRef);
int main() {
vector<room> roomRef;
valueSet(roomRef);
int curRoom = 0;
cout << roomRef[0].descOut;
return 0;
}
void valueSet(vector<room>& roomRef) {
roomRef.push_back(room(0, "You are outside.")); // Exterior
roomRef.push_back(room(1, "You are in room 1.")); // Room 1
roomRef.push_back(room(2, "You are in room 2.")); // Room 2
roomRef.push_back(room(3, "You are in room 3.")); // Room 3
}