samedi 20 octobre 2018

How to modify the width of a base function inherited by two different derived functions

My goal is to make the program looks the same as the expected output, so I have to modify the space that I print out. I'm using two functions to print out stuff, these two functions are member of a derived class inheriting the same print function of the base class. However, the output wants to have different widths for both derived functions. I tried cout << setw() and cout.width() but none of them work. I thought this is simple but I cannot find the solution. Hope you guys can help!

As you can see, in the Base function, there are 5 spaces at the beginning. However, my first derived function want to have 4 spaces only. How can I manipulate the function so that it only applies as 4 spaces for first derived function and 5 spaces for second derived function? Thank you!

First derived function https://i.stack.imgur.com/QFXpA.png

Second derived function https://i.stack.imgur.com/4EBH1.png

Base function https://i.stack.imgur.com/xvwZO.png

Aucun commentaire:

Enregistrer un commentaire