+ 6

What is getname setname? In c++

22nd Feb 2018, 9:32 AM
Jay Jay
Jay Jay - avatar
2 Antworten
+ 5
Here is an example: class Person{ string name; public: string getName(){ return name } void setName(string newName){ name = newName; } }; int main(){ // create an object Person (see your other // question Person p1; //set the name of p1 to Jimmy p1.setname("Jimmy"); //get the name of object p1 cout << p1.getName(); } If anything is unclear feel free to ask.
22nd Feb 2018, 10:15 AM
Alex
Alex - avatar