小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

實現(xiàn)客戶機(Client)類

 古羅 2007-11-16
#ifndef CLIENT_H #define CLIENT_H #include using namespace std; #include class Client { private: static string ServerName; static int ClientNum; static const int MAX = 10; string ClientName[MAX]; public: static void ChangeServerName(); void AddClient(); int Menu()const; friend ostream & operator<<( ostream &, const Client & ); }; #endif // 實現(xiàn)文件 #include "client.h" string Client::ServerName = "Server"; int Client::ClientNum = 0; void Client::ChangeServerName() { cin.ignore(); cout << "原來的服務器名稱:"<< ServerName << endl; cout << "輸入新的服務器名稱:"; getline( cin, ServerName ); cout << "現(xiàn)在的服務器名稱:" << ServerName << endl; } void Client::AddClient() { cin.ignore(); cout<<"輸入新增加的客戶的名稱:"; getline(cin,ClientName[ClientNum]); ++ClientNum; } int Client::Menu()const { int choice; cout<<"1、添加客戶 "; cout<<"2、更改服務器名稱 "; cout<<"3、顯示客戶信息 "; cout<<"4、退出 "; cout<<"請選擇所要執(zhí)行的操作: "; cin>>choice; return(choice); } ostream & operator<< ( ostream & os, const Client & client ) { os << "服務器名稱:" << client.ServerName << endl; os << "現(xiàn)有客戶數(shù)量:" << client.ClientNum << endl; os << "現(xiàn)有客戶的名稱: " ; if ( client.ClientNum == 0 ) os << "sorry,目前沒有客戶端連接。" << endl; else { os << endl; for( int i = 0; i < client.ClientNum; i++ ) ...{ os << "#" << i << ": " ; os << client.ClientName[i] << endl; } } return os; } //主函數(shù) #include "client.h" void main() { Client c; while(1) { int choice=c.Menu(); switch(choice) { case 1: c.AddClient(); break; case 2: c.ChangeServerName(); break; case 3: cout << c; break; case 4: return; } } }

    本站是提供個人知識管理的網絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內容,請點擊一鍵舉報。
    轉藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多