Advertisement
Guest User

Untitled

a guest
May 12th, 2017
553
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. #include <iostream>
  2. #include <list>
  3. using namespace std;
  4.  
  5. /*
  6. class Date
  7. {
  8. private:
  9. int year, month, day;
  10. public:
  11. Date(int y, int m, int d) { year = y; month = m; day = d; }
  12. bool operator=(const Date d)
  13. {
  14.  
  15. }
  16.  
  17. };
  18. */
  19.  
  20. class UniMember
  21. {
  22. private:
  23. string name, e_mail, dob;
  24.  
  25. public:
  26. UniMember(string n, string e, string d);
  27. virtual void print();
  28. };
  29.  
  30. void UniMember::print(){
  31. cout << "UniMember name: "<<name<<endl;
  32. cout << "UniMember e_mail: "<<e_mail<<endl;
  33. }
  34.  
  35. UniMember::UniMember(string n, string e, string d)
  36. : name(n), e_mail(e), dob(d)
  37. {
  38. cout << "UniMem init" << endl;
  39. }
  40.  
  41.  
  42. class Student : public UniMember
  43. {
  44. private:
  45. int admissionYear;
  46. list<string> courses;
  47.  
  48. public:
  49. Student(string n, string e, string d, int y, list<string> coursesList);
  50. void print();
  51.  
  52. };
  53. void Student :: print (){
  54. cout <<"Student Admission Year: "<<admissionYear<<endl;
  55. }
  56. Student :: Student(string n, string e, string d, int y, list<string> coursesList)
  57. : UniMember(n, e, d), admissionYear(y), courses(coursesList)
  58. {
  59. cout << "student init" << endl;
  60. }
  61.  
  62. class Teacher : public UniMember
  63. {
  64. private:
  65. string dob;
  66. list<string> courses;
  67.  
  68. public:
  69. Teacher(string n, string e, string d, list<string> coursesList);
  70. void print();
  71.  
  72. };
  73. void Teacher :: print(){
  74. cout <<"Teacher DOB: " << dob<<endl;
  75. UniMember::print();
  76. }
  77. Teacher :: Teacher(string n, string e, string d, list<string> coursesList)
  78. : UniMember(n, e, d), courses(coursesList)
  79. {
  80. cout << "teacher init" << endl;
  81. }
  82.  
  83. void test1()
  84. {
  85. UniMember* pUniMember;
  86. list<string> L = { "maths", "c++", "stuff" };
  87. pUniMember = new Student{"John", "john@stud.com", "1827-05-28", 1997, L};
  88.  
  89. list<string> tL = { "theory of something", "physics" };
  90. pUniMember = new Teacher {"Peter", "boss@uni.ro", "1672-02-12", tL};
  91. pUniMember->print();
  92.  
  93. Teacher* pTeacher;
  94. pTeacher = new Teacher {"Ralph", "ralph@uni.ro", "1972-02-12", tL};
  95. // pTeacher = new UniMember { ""}
  96. }
  97.  
  98. void test_lab10_1(){
  99. list<UniMember*>uList;
  100. uList.push_back(new Teacher{"Ralph", "ralph@uni.ro", "1972-02-12"});
  101. uList.push_back(new Student{"John", "john@stud.com", "1827-05-28", 1997,});
  102. uList.push_back(new UniMember{"DASAS","asd@asd.com","123-123-123"});
  103. for (list<UniMember*>::iterator it = uList.begin();it!=uList.end();++it){
  104. (*it)->print();
  105. }
  106.  
  107.  
  108.  
  109.  
  110. }
  111.  
  112.  
  113. int main()
  114. {
  115. // UniMember Andrew{"Andrew", "andrew@uni.com", "2017-04-12"};
  116. //
  117. // list<string> L = { "maths", "c++", "stuff" };
  118. // Student John{"John", "john@stud.com", "1827-05-28", 1997, L};
  119. //
  120. // list<string> tL = { "theory of chibrit", "boring stuff III" };
  121. // Teacher Peter{"Peter", "boss@uni.ro", "1672-02-12", tL};
  122.  
  123. return 0;
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement