Advertisement
thangpham113

Untitled

Dec 11th, 2018
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <string>
  4. using namespace std;
  5.  
  6. class SV{
  7. private:
  8. int lop;
  9. string HoTen;
  10. public:
  11. virtual void nhap(){
  12. cout<<"Lop:"; cin>>lop;
  13. cout<<"Ho Ten:"; fflush(stdin); getline(std::cin,HoTen);
  14. }
  15. virtual void xuat(){
  16. cout<<endl<<"Lop:"<<lop;
  17. cout<<endl<<"HoTen:"<<HoTen;
  18. }
  19. };
  20.  
  21. class SVSP:public SV{
  22. private:
  23. int HocBong;
  24. public:
  25. void nhap()
  26. {
  27. SV::nhap();
  28. cout<<"Hoc bong:"; cin>>HocBong;
  29. }
  30. void xuat()
  31. {
  32. SV::xuat();
  33. cout<<endl<<"Hoc bong:"<<HocBong;
  34. }
  35. };
  36.  
  37. class SVTC:public SV{
  38. private:
  39. int HocPhi;
  40. public:
  41. void nhap()
  42. {
  43. SV::nhap();
  44. cout<<"Hoc phi:"; cin>>HocPhi;
  45. }
  46. void xuat()
  47. {
  48. SV::xuat();
  49. cout<<endl<<"Hoc phi:"<<HocPhi;
  50. }
  51. };
  52.  
  53. int main()
  54. {
  55. SV* A[3]; //SVSP
  56. SV* B[3]; //SVTC
  57.  
  58. for(int i=0;i<3;i++)
  59. {
  60. A[i] = new SVSP;
  61. A[i]->nhap();
  62. }
  63. for(int i=0;i<3;i++)
  64. {
  65. B[i] = new SVTC;
  66. B[i]->nhap();
  67. }
  68. cout<<"Thong tin cac sinh vien su pham la";
  69. for(int i=0;i<3;i++)
  70. {
  71. A[i]->xuat();
  72. cout<<endl;
  73. }
  74. cout<<endl<<"Thong tin cac sinh vien tai chuc la:";
  75. for(int i=0;i<3;i++)
  76. {
  77. B[i]->xuat();
  78. cout<<endl;
  79. }
  80. return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement