[cpp] Person.cpp

Viewer

copydownloadembedprintName: Person.cpp
  1. #include "Person.h"
  2.  
  3. using namespace std;
  4.  
  5. Person::Person(){
  6.     name = "<no name>";
  7.     age = 0;
  8. }
  9.  
  10. void Person::setName(string newName){
  11.     name = newName;
  12. }
  13.  
  14. string Person::toString(){
  15.     stringstream info;
  16.     info << "[name: " << name << " age: " << age << "]";
  17.     return info.str();
  18. }
  19.  
  20. string Person::getName(){
  21.     return name;
  22. }
  23.  
  24. void Person::setAge(unsigned int newAge){
  25.     age = newAge;
  26. }
  27.  
  28. unsigned int Person::getAge(){
  29.     return age;
  30. }
  31.  

Editor

You can edit this paste and save as new:


File Description
  • Person.cpp
  • Paste Code
  • 11 Dec-2023
  • 483 Bytes
You can Share it: