Advertisement
Guest User

user

a guest
Jan 20th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4. #include <vector>
  5. #include <list>
  6. #include <algorithm>
  7. #include <conio.h>
  8.  
  9. using namespace std;
  10.  
  11. class User
  12. {
  13. private:
  14. string u_id;
  15. string u_gr;
  16. string u_subgr;
  17. static string id;
  18. public:
  19. User()
  20. {
  21. u_id = "";
  22. u_gr = "";
  23. u_subgr = "";
  24. }
  25. User(string a, string b, string c)
  26. {
  27. u_id = a;
  28. u_gr = b;
  29. u_subgr = c;
  30. }
  31. static string check(User &a)
  32. {
  33. return a.id == a.u_gr;
  34. }
  35. bool operator==(User &a)const
  36. {
  37. return (u_id == a.u_id && u_gr == a.u_gr && u_subgr == a.u_subgr);
  38. }
  39. bool operator<(User &a)
  40. {
  41. return (u_id < a.u_id && u_gr < a.u_gr && u_subgr < a.u_subgr);
  42. }
  43. friend istream& operator>>(istream& in, User &a)
  44. {
  45. in >> a.u_id >> a.u_gr >> a.u_subgr;
  46. return in;
  47. }
  48. friend ostream& operator<<(ostream& out, User &a)
  49. {
  50. out << a.u_id << " " << a.u_gr << " " << a.u_subgr << endl;
  51. return out;
  52. }
  53. };
  54.  
  55. class Network
  56. {
  57. private:
  58. string n_netname;
  59. vector<User>n_obj;
  60. public:
  61. Network(string f)
  62. {
  63. ifstream ifile(f, ios::in);
  64. if (ifile.is_open())
  65. {
  66. ifile >> n_netname;
  67. copy(n_obj.begin(), !ifile.eof());
  68. ifile.close();
  69. }
  70. else
  71. {
  72. cout << "File couldn't be opened!";
  73. exit(1);
  74. }
  75. }
  76. void setn(string a)
  77. {
  78. n_netname = a;
  79. }
  80. string getn()
  81. {
  82. return n_netname;
  83. }
  84. list<string> create(vector<User>v) // 2.3
  85. {
  86. list<string>unq;
  87. unique_copy(v.begin(), v.end(), unq);
  88. return unq;
  89. }
  90. friend istream& operator>>(istream& in, Network &a)
  91. {
  92. in >> a.n_netname;
  93. a.n_obj.push_back(in);
  94. return in;
  95. }
  96. friend ostream& operator<<(ostream& out, Network &a)
  97. {
  98. out << a.n_netname;
  99. copy(a.n_obj.begin(), a.n_obj.end());
  100. return out;
  101. }
  102. };
  103.  
  104. int main()
  105. {
  106. Network a("neshtosi");
  107. cout << a;
  108. a.create(a.n_obj);
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement