才新学的知识类;
#pragma once
#include
#include<atlstr.h>
using namespace std;
class cClient {
public:
cClient() {
ClientNum++;
}
void SetServerName(string server);
void GetServerName();
void SetName(CString name);
void GetName();
~cClient() { }
private:
static string Server;//保留所连接的服务器的名称
static int ClientNum;//记录已经实例化对象的数量
CString Name;
};
#include"client.h"
void cClient::SetServerName(string server) {
Server = server;
}
void cClient::GetServerName() {
cout << "所连接的服务器为:" << Server << endl;
}
void cClient::SetName(CString name) {
Name = name;
}
void cClient::GetName() {
cout << "实例化对象名称为:" << Name << endl;
}
int cClient::ClientNum = 0;
#include
#include"client.h"
using namespace std;
int main() {
cClient c1;
c1.SetServerName("CSBQ");
c1.GetServerName();
c1.SetName("1号");
c1.GetName();
return 0;
}