Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <list>
- #include <iterator>
- #include <fstream>
- using namespace std;
- class cstudent
- {
- private:
- vector <double> grades;
- protected:
- string fnum;
- public:
- cstudent(string getfnum)
- {
- fnum = getfnum;
- }
- cstudent(const cstudent& obj)
- {
- fnum = obj.fnum;
- }
- void set_fnum(string getfnum)
- {
- fnum = getfnum;
- }
- string getfnum()
- {
- return fnum;
- }
- virtual double avgcalc()
- {
- if (grades.size() > 0)
- {
- vector<double>::iterator iter;
- double avg_grade(0);
- for (iter = grades.begin(); iter != grades.end(); iter++)
- {
- avg_grade += (*iter);
- }
- avg_grade = avg_grade / grades.size();
- return avg_grade;
- }
- }
- friend ostream& operator <<(ostream& out, const cstudent& obj)
- {
- out << obj.fnum;
- return out;
- }
- friend istream& operator >>(istream& in, cstudent& obj)
- {
- in >> obj.fnum;
- return in;
- }
- cstudent operator =(cstudent& obj)
- {
- fnum = obj.fnum;
- return *this;
- }
- };
- class examBook
- {
- string discipline;
- int discPoints;
- public:
- examBook() {}
- examBook(string getdiscipline, int getdiscPoints)
- {
- discipline = getdiscipline; discPoints = getdiscPoints;
- }
- string getdiscipline() {
- return discipline;
- }
- int getdiscPoints() {
- return discPoints;
- }
- void show()
- {
- cout << getdiscipline();
- cout << endl << getdiscipline();
- }
- friend ostream& operator <<(ostream& out, const examBook& obj)
- {
- return (out << obj.discipline << endl << obj.discPoints << endl);
- }
- friend istream& operator >>(istream& in, examBook& obj) {
- in >> obj.discipline;
- in >> obj.discPoints;
- return in;
- }
- };
- class cstudentbook : public cstudent
- {
- list<examBook> listOfBooks;
- public:
- cstudentbook() {};
- void setList(examBook& obj)
- {
- listOfBooks.push_back(obj);
- }
- void show()
- {
- list<examBook>::iterator iter;
- for (iter = listOfBooks.begin(); iter != listOfBooks.end(); iter++)
- {
- (*iter).show();
- }
- }
- };
- int main()
- {
- examBook predmet("matematika", 10),predmet2("istoriq",40);
- cstudentbook obekt;
- obekt.setList(predmet);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement