Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class University {
- public:
- University(string name, int year);
- ~University() = default;
- virtual void info() const;
- protected:
- string name;
- int year;
- };
- University::University(string name, int year) {
- this->name = name;
- this->year = year;
- }
- void University::info() const {
- cout << "name: " << name <<
- "\nyear: " << year << endl;
- }
- class doctoralStudent :
- protected University {
- public:
- doctoralStudent(int scholarship, int articles, string name, int year);
- ~doctoralStudent() = default;
- void info() const;
- int getArt() { return articles; }
- int getScho() { return scholarship; }
- void setScho(int scho) { scholarship = scho; }
- protected:
- int scholarship;
- int articles;
- };
- doctoralStudent::doctoralStudent(int scholarship, int articles, string name, int year):
- University(name, year), scholarship(scholarship), articles(articles){}
- void doctoralStudent::info() const{
- University::info();
- cout << "\nscholarship: " << scholarship <<
- "\narticles: " << articles << endl;
- }
- class Proffesor :
- protected doctoralStudent {
- public:
- Proffesor(string, int, int, int, string, int);
- ~Proffesor() = default;
- void info() const;
- int getExp() { return experience; }
- void setExp(int exp) { experience = exp; }
- private:
- string position;
- int experience;
- };
- Proffesor::Proffesor(string pos, int exp, int scho, int art, string name, int year):
- doctoralStudent(scho, art, name, year){
- position = pos;
- experience = exp;
- }
- void Proffesor::info() const{
- doctoralStudent::info();
- cout << "\nposition: " << position <<
- "\nexperience: " << experience << endl;
- }
- int main() {
- University* TSU = new University("TSU", 1881);
- doctoralStudent* stud = new doctoralStudent(2000, 6, "MIT", 1995);
- Proffesor* prof = new Proffesor("LECTURER", 10, 5000, 25, "TSU", 1881);
- cout << "University: " << endl;
- TSU->info();
- cout << endl;
- cout << "Student: " << endl;
- stud->info();
- cout << endl;
- cout << "Proffesor: " << endl;
- prof->info();
- int tmp = prof->getExp();
- prof->setExp(tmp + 5);
- tmp = stud->getScho();
- if (stud->getArt() > 4) {
- stud->setScho(tmp * 3);
- }
- cout << "Proffesor: " << endl;
- prof->info();
- cout << endl;
- cout << "Student: " << endl;
- stud->info();
- delete TSU;
- delete stud;
- delete prof;
- }
Add Comment
Please, Sign In to add comment