+ 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; }
3 Réponses
+ 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
+ 1
Because you aren't writing to the console.
Try putting this in main()
cout << "Here's some output";
+ 1
ain't printing anywhere