class PERSON
{
private:
char name[10];
int age;
int height;
public:
PERSON();
public:
int SetName(char*);
int SetAge(int);
int SetHeight(int);
public:
char* GetName();
int GetAge(int&);
int GetHeight(int&);
};
PERSON::PERSON()
{
name[0]='\0';
age=0;
height=0;
}
int PERSON::SetName(char* pName)
{
strcpy(name,pName);
return 0;
}
char* PERSON::GetName()
{
char pName[10];
strcpy(pName,name);
return pName;
}
int PERSON::SetAge(int pAge)
{
age=pAge;
return 0;
}
int PERSON::GetAge(int& pAge)
{
pAge=age;
return 0;
}
int PERSON::SetHeight(int pHeight)
{
height=pHeight;
return 0;
}
int PERSON::GetHeight(int& pHeight)
{
pHeight=height;
return 0;
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include"person.h"
int main()
{
PERSON person();
char name[10]="jack";
person.SetName(name);
//strcpy(name,person.GetName());
int age=10;
person.SetAge(10);
age=0;
person.GetAge(age);
printf("%s",name);
printf("%d",age);
_getch();
return 0;
}