0
Shouldn't we use pointer here
class myClass { public: myClass() { cout <<"Hey"; } void setName(string x) { name = x; } string getName() { return name; } private: string name; }; the setName function permanently sets the value of the string - name to string - x. why is this not similar to putting argument by value (and not by reference) in function, when in that case the string called name shouldn't have been modified permanently.
0 Antworten