C++ class | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

C++ class

hi, what is wrong with my code? why it does not have any output? #include <iostream> #include <string> using namespace std; class myClass { public: void setName(string x) { x = name; } string getName() { return name; } private: string name; }; int main () { myClass myObj; myObj.setName("dar"); cout << myObj.getName(); return 0; }

9th Dec 2017, 5:06 PM
Dariush Shiri
Dariush Shiri - avatar
1 Answer
+ 3
thank you
9th Dec 2017, 5:15 PM
Dariush Shiri
Dariush Shiri - avatar