Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- #include <vector>
- #include <list>
- #include <algorithm>
- #include <conio.h>
- using namespace std;
- class User
- {
- private:
- string u_id;
- string u_gr;
- string u_subgr;
- static string id;
- public:
- User()
- {
- u_id = "";
- u_gr = "";
- u_subgr = "";
- }
- User(string a, string b, string c)
- {
- u_id = a;
- u_gr = b;
- u_subgr = c;
- }
- static string check(User &a)
- {
- return a.id == a.u_gr;
- }
- bool operator==(User &a)const
- {
- return (u_id == a.u_id && u_gr == a.u_gr && u_subgr == a.u_subgr);
- }
- bool operator<(User &a)
- {
- return (u_id < a.u_id && u_gr < a.u_gr && u_subgr < a.u_subgr);
- }
- friend istream& operator>>(istream& in, User &a)
- {
- in >> a.u_id >> a.u_gr >> a.u_subgr;
- return in;
- }
- friend ostream& operator<<(ostream& out, User &a)
- {
- out << a.u_id << " " << a.u_gr << " " << a.u_subgr << endl;
- return out;
- }
- };
- class Network
- {
- private:
- string n_netname;
- vector<User>n_obj;
- public:
- Network(string f)
- {
- ifstream ifile(f, ios::in);
- if (ifile.is_open())
- {
- ifile >> n_netname;
- copy(n_obj.begin(), !ifile.eof());
- ifile.close();
- }
- else
- {
- cout << "File couldn't be opened!";
- exit(1);
- }
- }
- void setn(string a)
- {
- n_netname = a;
- }
- string getn()
- {
- return n_netname;
- }
- list<string> create(vector<User>v) // 2.3
- {
- list<string>unq;
- unique_copy(v.begin(), v.end(), unq);
- return unq;
- }
- friend istream& operator>>(istream& in, Network &a)
- {
- in >> a.n_netname;
- a.n_obj.push_back(in);
- return in;
- }
- friend ostream& operator<<(ostream& out, Network &a)
- {
- out << a.n_netname;
- copy(a.n_obj.begin(), a.n_obj.end());
- return out;
- }
- };
- int main()
- {
- Network a("neshtosi");
- cout << a;
- a.create(a.n_obj);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement