// Three files are in this paste!
// person.h - a list of prototypes for member functions contained in class.cpp
#include <string>
using namespace std;
// the class person holds member functions relating to details about a person.
class person
{
public:
person ( string, int, int); // Prototype for the constructer.
void setName(string); // Prototype for the member function setName.
void setAge(int); // Prototype for the member function setAge.
void setWeight(int); // Prototype for the member function setWeight.
int getAge(); // Prototype for getAge.
string getName(); // Prototype for getName().
// setup member data.
private:
string personName;
int personAge;
int personWeight;
};
// class.cpp
#include <string>
#include "person.h"
using namespace std;
person::person(string name, int age, int weight) // Setup our constructor to set default values for member data.
{
setName(name);
setAge(age);
setWeight(weight);
}
void person::setName(string name) // The setName member function..
{
if ( name.length() <= 10 ) { personName = name; } // assign name to personName if name is less than or equal to 10(11 from 0).
else { name = name.substr(0,10); personName = name; } // truncate name to 10(11 counting from 0) characters if it exceeds that amount.
}
void person::setAge(int age) // the setAge member function..
{
personAge = age;
}
void person::setWeight(int weight) // The setWeight member function.
{
personWeight = weight;
}
int person::getAge() // The setAge member fucntion.S
{
return personAge;
}
string person::getName() // The getName member function.
{
return personName;
}
// interface.cpp
#include <iostream>
#include <string>
#include "person.h"
using std::cout;
int main()
{
person personObject(0, 0,0);
return (0);
}