Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <list>
- #include <iterator>
- #include <stdlib.h>
- #include <string>
- using namespace std;
- class Persoana {
- private:
- static Persoana *head;
- Persoana *next;
- string nume, prenume, numeLiceu;
- public:
- Persoana(string nume, string prenume, string numeLiceu){
- this->nume = nume;
- this->prenume = prenume;
- this->numeLiceu = numeLiceu;
- this->next = NULL;
- if (head == NULL) {
- head = this;
- return;
- }
- if (head->nume > this->nume) {
- this->next = head;
- head = this;
- return;
- }
- Persoana *q = head;
- while (q->next && q->next->nume < this->nume) q = q->next;
- this->next = q->next;
- q->next = this;
- }
- virtual void Show() {
- cout << "\nNume: "<< nume;
- cout << "\nPrenume: " << prenume;
- cout << "\nNume Liceu: " << numeLiceu;
- }
- };
- class Profesor : public Persoana {
- private:
- string materie, gradDidactic;
- unsigned short vechime;
- double salar;
- public:
- Profesor(string nume, string prenume, string numeLiceu, string materie, string gradDidactic, unsigned short vechime, double slar) :Persoana(nume, prenume, numeLiceu) {
- this->gradDidactic = gradDidactic;
- this->materie = materie;
- this->vechime = vechime;
- this->salar = salar;
- }
- void Show() {
- Persoana::Show();
- cout << "\nMaterie: " << materie;
- cout << "\nGrad Didactic: " << gradDidactic;
- cout << "\nVechime: " << vechime;
- cout << "\nSalariu: " << salar;
- }
- };
- class Elev : public Persoana {
- private:
- string specializare;
- unsigned short an;
- double mediaGen;
- public:
- Elev(string nume, string prenume, string numeLiceu, string specializare, unsigned short an, double mediaGen) :Persoana(nume, prenume, numeLiceu) {
- this->specializare = specializare;
- this->an = an;
- this->mediaGen= mediaGen;
- }
- void Show() {
- Persoana::Show();
- cout << "\nSpecializare: " << specializare;
- cout << "\nAn: " << an ;
- cout << "\nMedia Generala: " << mediaGen;
- }
- };
- ostream& operator<<(ostream& iesire, Profesor &P)
- {
- iesire << "Date despre persoana" << endl;
- P.Show();
- return iesire;
- }
- ostream& operator<<(ostream& iesire, Elev &E)
- {
- iesire << "Date despre persoana" << endl;
- E.Show();
- return iesire;
- }
- int main() {
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment