Getting "no output" why is this? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Getting "no output" why is this?

#include <iostream> #include <string> using namespace std; class myClass { public: void setName(string x) { name = x; } private: string name; }; int main() { myClass myObj; myObj.setName("John"); return 0; }

16th Apr 2018, 1:30 AM
Sir
3 Answers
+ 12
Sir u forgot console output In class myClass inside setName function write cout<<name; after name = x; here's the correct one 👇 https://code.sololearn.com/c3hjqk82GpdU/?ref=app
16th Apr 2018, 4:44 AM
🌛DT🌜
🌛DT🌜 - avatar
+ 1
Because you aren't writing to the console. Try putting this in main() cout << "Here's some output";
16th Apr 2018, 1:45 AM
Emma
+ 1
ain't printing anywhere
23rd Apr 2018, 6:54 AM
Parth Sinha
Parth Sinha - avatar