Answer to Question #31783 in C++ for Jay

Question #31783
Implement all member functions of the following class:
class Person
{
public:
Person();
Person(string pname, int page);
void get_name() const;
void get_age() const;
private:
string name;
int age; // 0 if unknown
};
1
Expert's answer
2013-06-11T08:58:49-0400
#include <string>
using namespace std;

class Person
{
public:
Person();
Person(string pname, int page);
string get_name() const;
int get_age() const;
private:
string name;
int age; // 0 if unknown
};


Person::Person() {
name = "";
age = 0;
}

Person::Person(string pname, int page) {
name = pname;
age = page;
}

string Person::get_name() const {
return name;
}

int Person::get_age() const {
return age;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS