#include<iostream>
#include<string.h>
using namespace std;
class CPerson
{
private:
char name[12];
int age;
float height;
long friendID;
int IsMyFriend(long fid);
public:
void PubPrivate(long fid);
void SetPrivate(char *n = " ", int a = 0, float h = 0);
void SetFriendID(long fid = 12345);
};
int CPerson::IsMyFriend(long fid)
{
return fid == friendID ? 1 : 0;
}
void CPerson::PubPrivate(long fid)
{
cout << "hello" << endl;
if (IsMyFriend(fid))
cout << "My friend:I am " << name
<< "," << age << " years old,and my height is " << height << endl;
else
cout << "Sorry,you are not my friend" << endl;
}
void CPerson::SetPrivate(char *n, int a, float h)
{
strcpy(name, n);
age = a;
height = h;
}
void CPerson::SetFriendID(long fid)
{
friendID = fid;
}
void main(void)
{
CPerson me, *pme = &me;
(*pme).SetPrivate("Tom", 18, 185);
pme->SetFriendID(45678);
me.PubPrivate(4567);
(*pme).PubPrivate(45678);
cout << sizeof(CPerson) << endl;
system("pause");
}
问题是无法调试
__YXQ__
慕瓜9220888
相关分类