+ 1

Questions about constructors in SOLOLEARN example

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(); } //Outputs "David" It seems that there isn't any difference without void before setName. Am I right?

16th Oct 2018, 2:40 AM
æž—ć…‹çż°
1 Answer
0
Yes, setName doesnt return any value.
22nd Jan 2019, 1:25 PM
LetterC67
LetterC67 - avatar