Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- #include<algorithm>
- #include<string>
- using namespace std;
- class young{
- protected:
- string fn;
- int age;
- public :
- young(string a = "julia", int b = 20){
- fn = a;
- age = b;
- }
- ~young(){}
- friend istream& operator>>(istream&, young &);
- friend ostream& operator<<(ostream&, young &);
- };
- class university {
- protected:
- string name;
- int fakult;
- public:
- university(string a = "tsu", int b = 18){
- name = a;
- fakult = b;
- }
- ~university(){}
- friend istream& operator>>(istream&, university &);
- friend ostream& operator<<(ostream&, university&);
- };
- class student : public young, public university{
- protected:
- string specialoba;
- double grade;
- public:
- student(string a = "julia", int b = 20, string c = "tsu", int d = 18, string g = " matemati", double k = 2.3) :
- young(a, b), university(c, d), specialoba(g), grade(k){}
- ~student(){}
- double getgrade(){ return grade; }
- friend istream& operator>>(istream&, student&);
- friend ostream& operator<<(ostream&, student&);
- };
- istream& operator>>(istream&ifs, young &h){
- return ifs >> h.fn >>h. age;
- }
- ostream& operator<<(ostream&ofs, young &h){
- return ofs << " saxelia " << h.fn << " age " <<h. age << endl;
- }
- istream& operator>>(istream&ifs, university&h){
- return ifs >>h. name >>h. fakult;
- }
- ostream& operator<<(ostream&ofs, university &h){
- return ofs << " uni saxelia " << h.name << " fakraod " << h.fakult << endl;
- }
- istream& operator >> (istream &ifs, student &k){
- ifs >> (young &)k >> (university&)k >> k.specialoba >> k.grade;
- return ifs;
- }
- ostream & operator<<(ostream &ofs, student &l){
- ofs << (young &)l << (university&)l << "speciealoba : " << l.specialoba << " grade: " << l.grade << endl;
- return ofs;
- }
- int main(){
- young a;
- cout << " shemoitane youngis monacemi : " << endl;
- cin >> a;
- university *x;
- x=new university("tsu", 10);
- cout << a;
- cout << &x;
- student * y = new student[3];
- ifstream ifs("text.txt");
- for (int i = 0; i < 3; i++)
- ifs >> y[i];
- sort(y, y + 3, [](student &a, student &b) {return a.getgrade()>b.getgrade(); });
- ofstream ofs("ratee.txt");
- for (int i = 0; i < 3; i++)
- ofs << y[i];
- delete x;
- delete [] y;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement