0

Why doesn't the code output a name?

#include <iostream> using namespace std; class myClass { public: myClass(string nm) { setName(nm); } void setName(string x) { name = x; } string getName() { return name; } private: string name; }; int main() { myClass ob1("David"); myClass ob2("Amy"); cout << ob1.getName(); }

9th Jul 2017, 2:55 PM
NoDog
NoDog - avatar
3 Answers
0
thanks guys!
9th Jul 2017, 5:50 PM
NoDog
NoDog - avatar