#include <iostream> #include <string>using namespace std;class person{string name; bool gender; int age; Person *lover;public:person (const char *n= "nameless", bool g=true); void growup (int years); void Show ();}; Person::P Erson (const char *n,bool g/*=true*/) {name=n;gender=g;age=0;lover=null;} void person::growup (int years) {age+=years;} void Person::show () {cout<< "Hello everyone, I am" << (gender?) Handsome ":" Beauty ") <<name<<", this year "<<age<<" years old. "<<endl;} int main () {Person A ("hibiscus", false); Person B ("Yong-ho", true); Person C ("two Dog"); Person D; Person e (); a.growup (b.growup); A.show (); B.show (); c.growup (5); C.show ();d. Growup (+);d. Show (); E (). Show (); Person E () {string Name;bool gender;int age;cout<< "Please enter name, gender and age";cin>>name>>gender>>age; Person input (NAME.C_STR (), gender); the//C_STR () function returns a pointer to the regular C string with the same contents as this string string. Input.growup (age); return input;}
"C + + program" constructor