实现客户机client类.cpp 723 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include <iostream>
  2. #include <string>
  3. class Client {
  4. private:
  5. static std::string ServerName;
  6. static int ClientName;
  7. public:
  8. static void changeServerName(const std::string& newName) {
  9. ServerName = newName;
  10. }
  11. static void addClient(const std::string& clientName) {
  12. ClientName++;
  13. std::cout << clientName << std::endl;
  14. std::cout << ClientName << std::endl;
  15. }
  16. };
  17. std::string Client::ServerName = "DefaultServer";
  18. int Client::ClientName = 0;
  19. int main() {
  20. int numClients;
  21. std::cin >> numClients;
  22. std::string clientName;
  23. for (int i = 0; i < numClients; ++i) {
  24. std::cin >> clientName;
  25. Client::addClient(clientName);
  26. }
  27. return 0;
  28. }