Output aligned columns

In the class employee of print employee method: Use this line to print.

cout << setw(20) << left << surname << setw(10) << left << empNumber << setw(4) << hourlyRate << endl;

You forgot to add "<< left". This is required if you want left aligned.

Hope it ll useful.


You need to set a width before you print out the name to get other things to line up after that. Something on this general order:

cout << left << setw(15) << surname 
     << setw(10) << empNumber << "\t" 
     << setw(4) << hourlyRate << "\n";

I'd (at least normally) avoid trying to mix fixed-width fields with tabs as well. It's generally easier to just use widths to align things.

Tags:

C++

Cout