2
我怎樣才能使它在同一行?爲什麼我得到linebreaks?
它看起來像:
You see a closed door.
It belongs to house 'Magician's Alley
5a'.
Nobody owns this house.
但我希望它看起來像:
You see a closed door. It belongs to house 'Magician's Alley 5a'. Nobody owns this house.
代碼:
void House::updateDoorDescription()
{
std::stringstream houseDescription;
houseDescription << "It belongs to house '" << houseName << "'. " << std::endl;
if(houseOwner != 0){
houseDescription << houseOwnerName;
}
else{
houseDescription << "Nobody";
}
houseDescription << " owns this house." << std::endl;
HouseDoorList::iterator it;
for(it = doorList.begin(); it != doorList.end(); ++it){
(*it)->setSpecialDescription(houseDescription.str());
}
}
'endl'代表「end line」 – nico 2011-02-27 11:52:01