Guest User

Untitled

a guest
Feb 22nd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3. #include <vector>
  4. #include <string>
  5.  
  6. using std::vector;
  7. using std::string;
  8. using std::cout;
  9. using std::endl;
  10.  
  11. //--------class--------
  12. class Client {
  13. public:
  14. //constructor
  15. Client(string name, int ID) {
  16. this->ID = ID;
  17. this->name = name;
  18. }
  19. //function that returns ID of client
  20. int return_ID() {
  21. return ID;
  22. }
  23.  
  24. //function that returns name of client
  25. string return_name() {
  26. return name;
  27. }
  28.  
  29. private:
  30. int ID;
  31. string name;
  32. };
  33.  
  34. //---------------------------------------
  35. class Bank {
  36.  
  37. private:
  38.  
  39. //vector of clients
  40. vector<Client*> clients;
  41.  
  42.  
  43. public:
  44. //function for adding clients to vector
  45. void addclientd(Client* client) {
  46. clients.push_back(client);
  47. }
  48.  
  49. //function for printing data of clients
  50. void print() {
  51. for (int i = 0; i < clients.size(); i++) {
  52. cout << "ID is " << clients[i]->return_ID() << " ";
  53. cout << "Name is " << clients[i]->return_name() << endl;
  54. }
  55. }
  56.  
  57. };
  58.  
  59.  
  60.  
  61.  
  62. //---------------------------------
  63. int main() {
  64.  
  65.  
  66. Client Ivanov("Ivanov", 3234);
  67. Client Somebody("Somebody", 2345);
  68. Bank bank;
  69. bank.addclientd(&Ivanov);
  70. bank.addclientd(&Somebody);
  71.  
  72. bank.print();
  73.  
  74. system("pause");
  75. return 0;
  76.  
  77. }
Add Comment
Please, Sign In to add comment