Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- #include <map>
- using namespace std;
- class Student
- {
- public:
- string name;
- };
- class StudentGroup
- {
- public:
- map <string, Student*> myMap;
- void insertio(Student *toAdd)
- {
- myMap[toAdd->name] = toAdd;
- };
- void display()
- {
- map<string, Student*>::iterator it;
- for (it = myMap.begin(); it != myMap.end(); it++)
- {
- cout << it->first << "|" << it->second << endl;
- }
- };
- StudentGroup operator*(StudentGroup *input)
- {
- StudentGroup temp;
- map<string, Student*>::iterator iter1, iter2;
- for (iter1 = this->myMap.begin(); iter1 != myMap.end(); iter1++)
- {
- for (iter2 = input->myMap.begin(); iter2 != input->myMap.end(); iter2++)
- {
- if (iter1->first == iter2->first && iter1->second == iter2->second) // <---- Czy zawsze będzie 1 & 1, albo 0 & 0 ?
- temp.insertio(iter1->second);
- }
- };
- return temp;
- };
- };
- void main()
- {
- Student *a = new Student;
- Student *b = new Student;
- Student *c = new Student;
- Student *d = new Student;
- a->name = "kok";
- b->name = "butt-blocker";
- c->name = "cock";
- d->name = "dick-tator";
- StudentGroup group;
- group.insertio(a);
- group.insertio(b);
- group.display();
- StudentGroup *groupOther = new StudentGroup;
- groupOther->insertio(c);
- groupOther->insertio(d);
- groupOther->insertio(a);
- cout << endl;
- groupOther->display();
- cout << endl;
- (group*groupOther).display();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement