as others have indicated, your map variable needs to be a data member of the class not in the local scope of the Seats constructor as you've posted
class Seats {
public:
Seats();
bool GetSeat(const string &);
void SetSeat(const string &, bool);
private:
map< string, bool > seat;
};
Seats::Seats() {
// merely your example values posted.
seat["A1"] = false;
seat["A2"] = false;
}
void Seats::SetSeat(const string &seat_number, bool occupied) {
seat[seat_number] = occupied;
}
bool Seats::GetSeat(const string &seat_number) {
return seat[seat_number];
}
keep in mind using the map's [] operator though can cause elements to be inserted into the data structure if they do not exist yet:
link text
T& operator[] ( const key_type& x );
If x does not match the key of any
element in the container, the function
inserts a new element with that key
and returns a reference to its mapped
value. Notice that this always
increases the map size by one, even if
no mapped value is assigned to the
element (the element is constructed
using its default constructor).