Code:
Beverage coke("coke", 3.65, false);
cout<<setprecision(3)<<coke.toString();
No matter what I change the setprecision parameter to, it always displays 3.9055. Is it because I am calling a function? toString() looks like this.
Code:
string Beverage::toString() {
ostringstream result;
if(isAlcoholic == true)
result<<getName()<<" is an alcoholic beverage."<<std::endl;
else
result<<getName()<<" is an non-alcoholic beverage."<<std::endl;
result<<"It's price is "<<getPrice()<<"."<<std::endl;
return result.str();
}