Shouldn't we use pointer here | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
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.

1st Jun 2018, 2:32 PM
Kasul Kliff
Kasul Kliff - avatar
0 Antworten