+ 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?
1 Answer
0
Yes, setName doesnt return any value.