C++中创建Client类

C++中创建Client类
2024-12-05 10:46:11
推荐回答(1个)
回答1:

#include
#include
using namespace std;
class Client
{
private:
char* m_name;
int m_age,m_type;
public:
Client( char* m_name,int m_age,int m_type)
{
this->m_name=m_name;
this->m_age=m_age;
this->m_type=m_type;
}
Client()
{
m_name="aaa";
m_age=20;
m_type=1;

}
void SetName(char *pName)
{
m_name=pName;
}
void GetName()
{
cout<<"名字为:"< }
void SetType(int type)
{
m_type=type;
}
void GetType()
{
cout<<"类型为:"< }
};
void display(Client c)
{
c.GetName();
c.GetType();
}
int main()
{
Client c("yyy",23,2);
c.SetName("rrrr");
c.SetType(2);
display(c);
}