Why when this code is running compiler is not stopping.
I know I can return name in class instead of print out here and cout it in main but
curious what is different?
Good practice with class design with respect to portability/reusability indicates/dictates that getters and setters preferably shouldn't be system/platform dependent.
What this means is getName not only should clearly return a string but the cout is better placed in main. So the statement in main() would be: