Advertisement
Alx09

Untitled

Nov 23rd, 2020
975
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.23 KB | None | 0 0
  1. #include <iostream>
  2. #include <list>
  3. #include <iterator>
  4. #include <stdlib.h>
  5. #include <string>
  6. using namespace std;
  7.  
  8. class Persoana {
  9. private:
  10.     static Persoana *head;
  11.     Persoana *next;
  12.     string nume, prenume, numeLiceu;
  13. public:
  14.     Persoana(string nume, string prenume, string numeLiceu){
  15.         this->nume = nume;
  16.         this->prenume = prenume;
  17.         this->numeLiceu = numeLiceu;
  18.         this->next = NULL;
  19.         if (head == NULL) {
  20.             head = this;
  21.             return;
  22.         }
  23.         if (head->nume > this->nume) {
  24.             this->next = head;
  25.             head = this;
  26.             return;
  27.         }
  28.         Persoana *q = head;
  29.         while (q->next && q->next->nume < this->nume) q = q->next;
  30.         this->next = q->next;
  31.         q->next = this;
  32.     }
  33.     virtual void Show() {
  34.         cout << "\nNume: "<< nume;
  35.         cout << "\nPrenume: " << prenume;
  36.         cout << "\nNume Liceu: " << numeLiceu;
  37.     }
  38. };
  39.  
  40. class Profesor : public Persoana {
  41. private:
  42.     string materie, gradDidactic;
  43.     unsigned short vechime;
  44.     double salar;
  45. public:
  46.     Profesor(string nume, string prenume, string numeLiceu, string materie, string gradDidactic, unsigned short vechime, double slar) :Persoana(nume, prenume, numeLiceu) {
  47.         this->gradDidactic = gradDidactic;
  48.         this->materie = materie;
  49.         this->vechime = vechime;
  50.         this->salar = salar;
  51.     }
  52.      void Show() {
  53.         Persoana::Show();
  54.         cout << "\nMaterie: " << materie;
  55.         cout << "\nGrad Didactic: " << gradDidactic;
  56.         cout << "\nVechime: " << vechime;
  57.         cout << "\nSalariu: " << salar;
  58.     }
  59.    
  60. };
  61.  
  62. class Elev : public Persoana {
  63. private:
  64.     string specializare;
  65.     unsigned short an;
  66.     double mediaGen;
  67. public:
  68.     Elev(string nume, string prenume, string numeLiceu, string specializare, unsigned short an, double mediaGen) :Persoana(nume, prenume, numeLiceu) {
  69.         this->specializare = specializare;
  70.         this->an = an;
  71.         this->mediaGen= mediaGen;
  72.     }
  73.     void Show() {
  74.         Persoana::Show();
  75.         cout << "\nSpecializare: " << specializare;
  76.         cout << "\nAn: " << an ;
  77.         cout << "\nMedia Generala: " << mediaGen;
  78.        
  79.     }
  80. };
  81.  
  82. ostream& operator<<(ostream& iesire, Profesor &P)
  83. {
  84.     iesire << "Date despre persoana" << endl;
  85.     P.Show();
  86.     return iesire;
  87. }
  88. ostream& operator<<(ostream& iesire, Elev &E)
  89. {
  90.     iesire << "Date despre persoana" << endl;
  91.     E.Show();
  92.     return iesire;
  93. }
  94.  
  95.  
  96. int main() {
  97.  
  98.  
  99.    
  100.     system("pause");
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement