// C++ language class Person { // declare a Person class to hold the data public: // list all public method prototypes Person(char*, int); // constructor, same as class, to provide data // don't need param needs, just types char *getName(); // accessor method to return stored name int getAge(); // accessor method to return stored age char *toString(); // conversion method to format the data private: // hide all the data in the class char *name; // each instance of Person will have this storage int age; // and storage for age }; Person:: Person(char *name, int age) { // now provide the implementations this->name = name; // "this" refers to the current instance // and acts as a memory ptr // this->is the storage up above // the r.h.s. name is the param to Person constructor this->age = age; // backup the age too } char* Person::getName() { // accessor methods returns the stored name return name; } int Person::getAge() { // accessor methods returns the stored age return age; } char* Person::toString() { // formatting method char *buffer = new char[50]; // declare memory sprintf(buffer,"%s %d",getName(),getAge());// format data similar to a printf return buffer; // return to caller for actual printing }