//m.cpp
#include "person.h"
void main()
{
Person zh("Zhang",50,‘m‘),c("Cai",35,‘w‘);
zh.Show();
c.Show();
}
//Person.h
#include<iostream>
#include<string>
using namespace std;
class Person
{
char name[10],sex; //姓名,性别
int age; //年龄
public:
Person(char *,int,char);
void Show(); //显示各属性
};
inline void Person::Show()
{
cout<<"name:"<<name;
cout<<",age:"<<age;
cout<<",sex:"<<sex<<endl;
}
//person.cpp
#include "person.h"
Person::Person(char *n,int a,char s)
{
strcpy(name,n);
age=a;
sex=s;
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。