I have a Hallway class that is made up of a vector of Rooms. I have two types of Rooms - Bathrooms and Bedrooms. The toString() function in Room is a virtual function that I want to be overloaded by Bathroom and Bedroom. Whenever I call Hallway's toString() function, I want it to go through and call each Room's toString() function. The problem is that instead of calling Bathroom's or Bedroom's toString(), it calls Room's toString(). I'm assuming it's because the Hallway is a vector of Room's and not Bathroom's or Bedroom's. But I thought it would call the appropriate virtual function if a Room is a subclass. How can I check what kind of Room each Room is, and call the appropriate toString()? Here is some code if it's needed

Code:
string Hallway::toString() {
	ostringstream result;
	result<<"The hallway consists of "<<getRoomVec().size()<<" rooms."<<endl;
	result<<"---------------------------------------------"<<endl;
	for(int i=0;i<getRoomVec().size();i++) {
		result<<getRoomVec().at(i).toString()<<endl;
	}
	result<<"---------------------------------------------"<<endl;
	return result.str();
}
Code:
string Bedroom::toString() {
	ostringstream result;
	result<<"The bedroom consists of: "<<endl;
	result<<"---------------------------------------------"<<endl;
	for(int i=0;i < getItemVec().size();i++) {
		result<<getItemVec().at(i).toString()<<endl;
	}
	result<<"---------------------------------------------"<<endl;
	if(areLightsOn())
		result<<"The bedroom's lights are on."<<endl;
	else
		result<<"The bedroom's lights are off."<<endl;
	result<<"The remaining length to the bedroom is "<<getAvailableL()<<"."<<endl;
	result<<"The remaining width to the bedroom is "<<getAvailableW()<<"."<<endl;
	return result.str();
}
Code:
string Bathroom::toString() {
	ostringstream result;
	result<<"The bathroom consists of: "<<endl;
	result<<"---------------------------------------------"<<endl;
	if(getShowerVec().size() > 0) {
		for(int i=0;i<getShowerVec().size();i++) 
			result<<getShowerVec().at(i).toString()<<endl;
	}
	if(getStallVec().size() > 0) {
		for(int i=0;i<getStallVec().size();i++)
			result<<getStallVec().at(i).toString()<<endl;
	}
	if(getSinkVec().size() > 0) {
		for(int i=0;i<getSinkVec().size();i++)
			result<<getSinkVec().at(i).toString()<<endl;
	}
	if(getMirrorVec().size() > 0) {
		for(int i=0;i<getMirrorVec().size();i++)
			result<<getMirrorVec().at(i).toString()<<endl;
	}
	result<<"---------------------------------------------"<<endl;
	if(areLightsOn())
		result<<"The bathroom's lights are on."<<endl;
	else
		result<<"The bathroom's lights are off."<<endl;
	result<<"The remaining length to the bathroom is "<<getAvailableL()<<"."<<endl;
	result<<"The remaining width to the bathroom is "<<getAvailableW()<<"."<<endl;
	return result.str();
}
Code:
string Room::toString() {
	string nothing;
	return nothing;
}
Code:
int main() {
	Bathroom room;
	Shower one;
	Shower two;
	Stall three;
	Stall four;
	Stall five;
	Mirror six;
	Sink seven;
	room.addShower(one);
	room.addShower(two);
	room.addStall(three);
	room.addStall(four);
	room.addStall(five);
	room.addMirror(six);
	room.addSink(seven);
	Hallway hall;
	hall.addBathroom(room);
	cout<<hall.toString();

	return 0;
}