分享

Person类的内嵌成员函数

 copperpea 2007-06-13
//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;
}

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多