+ 1
Whats the errror..?
#include<iostream> #include<string> using namespace std; class myclass{ public: void setname(string x ){ name =x; } string getname(){ return name; } private : string name ; }; int main(){ myclass myobj; myobj.setname("hhhhh"); cout<<myobj.setname(); }
2 Respostas
+ 4
You have this line:
cout<<myobj.setname(); // using setname() instead of getname()
+ 2
last line should be
cout << myobj.getname();