I am trying to have a function myCout
that have a string among its argument. This string is meant to set the alignment of the output. That is is if we have "left"
as argument
cout<<std::left;
should be executed .
I have attached my code below.
ostream & myAlign (string str) {
if (str == "left")
return std ::left ;
else
return std::right ;
}
template <class T>
void myCout (int width, char fill, T var, string a) {
cout << setw(width) << setfill(fill) << setprecision(2) << myAlign(a) << std:: fixed << var << "\t" <<flush ;
return ;
}
Thank you for your help in advance