You need to return a string in your getname()
function, since your name
variable is a string
string getname() {
return name;
}
By doing so, you get a new instance of std::string
as an rvalue
result, which is then outputted to the screen in your main function.
As another thought, not related to your problem though: there is no problem in using a namespace globally for small programs like this one, but you should try to not get used to it because it can lead to name conflicts within different namespaces in bigger projects.