Person类的内嵌成员函数

来源:百度文库 编辑:神马文学网 时间:2024/03/29 23:51:29
//m.cpp
#include "person.h"
void main()
{
Person zh("Zhang",50,‘m‘),c("Cai",35,‘w‘);
zh.Show();
c.Show();
}
//Person.h
#include
#include
using namespace std;
class Person
{
char name[10],sex; //姓名,性别
int age;   //年龄
public:
Person(char *,int,char);
void Show();  //显示各属性
};
inline void Person::Show()
{
cout<<"name:"<cout<<",age:"<cout<<",sex:"<}
//person.cpp
#include "person.h"
Person::Person(char *n,int a,char s)
{
strcpy(name,n);
age=a;
sex=s;
}