Advertisement
huutho_96

OOP week 7

May 13th, 2015
535
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. //https://www.facebook.com/pages/C%C3%B9ng-h%E1%BB%8Dc-l%E1%BA%ADp-tr%C3%ACnh/632038696941833
  2.  
  3. #include <iostream>
  4. #include <string>
  5. using namespace std;
  6. class NhanVien
  7. {
  8. protected:
  9. string HoTen, NgaySinh;
  10. int Luong;
  11. public:
  12. NhanVien(string HoTen = "", string NgaySinh = "")
  13. {
  14. this->HoTen = HoTen;
  15. this->NgaySinh = NgaySinh;
  16. }
  17. ~NhanVien(){};
  18. friend istream& operator >> (istream& in, NhanVien &NV)
  19. {
  20. fflush(stdin);
  21. cout << "Nhap ten: ";
  22. getline(in, NV.HoTen);
  23. cout << "Nhap ngay sinh: ";
  24. getline(in, NV.NgaySinh);
  25. return in;
  26. }
  27. friend ostream& operator << (ostream& out, NhanVien NV)
  28. {
  29. out << "Ten: " << NV.HoTen << "\nNgay sinh: " << NV.NgaySinh << endl;
  30. return out;
  31. }
  32. };
  33. class NVSanXuat : public NhanVien
  34. {
  35. public:
  36. NVSanXuat(string Ten = "", string NgaySinh = "", int LuongCanBan = 0, int SoSP = 0) : NhanVien(Ten, NgaySinh)
  37. {
  38. this->LuongCB = LuongCanBan;
  39. this->SoSP = SoSP;
  40. }
  41. ~NVSanXuat(){};
  42. int TinhLuong()
  43. {
  44. this->Luong = LuongCB + SoSP * 5000;
  45. return this->Luong;
  46. }
  47. friend istream& operator >> (istream& in, NVSanXuat &NV)
  48. {
  49. NhanVien *N = &NV;
  50. in >> *N;
  51. fflush(stdin);
  52. cout << "Nhap luong co ban: ";
  53. in >> NV.LuongCB;
  54. cout << "Nhap so SP: ";
  55. in >> NV.SoSP;
  56. return in;
  57. }
  58. friend ostream& operator << (ostream& out, NVSanXuat NV)
  59. {
  60. NhanVien *N = &NV;
  61. out << *N;
  62. out << "Luong co ban: " << NV.LuongCB << "\nSo san pham: " << NV.SoSP << "\nLuong: " << NV.TinhLuong() << endl;
  63. return out;
  64. }
  65. private:
  66. int LuongCB;
  67. int SoSP;
  68. };
  69.  
  70. class NVVanPhong : public NhanVien
  71. {
  72. public:
  73. NVVanPhong(string Ten = "", string NgaySinh = "", int SoNgayLam = 0) : NhanVien(Ten, NgaySinh)
  74. {
  75. this->SoNgayLam = SoNgayLam;
  76. }
  77. ~NVVanPhong(){};
  78. int TinhLuong()
  79. {
  80. this->Luong = SoNgayLam * 100000;
  81. return this->Luong;
  82. }
  83. friend istream& operator >> (istream& in, NVVanPhong &NV)
  84. {
  85. NhanVien *N = &NV;
  86. in >> *N;
  87. fflush(stdin);
  88. cout << "Nhap so ngay lam: ";
  89. in >> NV.SoNgayLam;
  90. return in;
  91. }
  92. friend ostream& operator << (ostream& out, NVVanPhong NV)
  93. {
  94. NhanVien *N = &NV;
  95. out << *N;
  96. out << "So ngay lam: " << NV.SoNgayLam << "\nLuong: " << NV.TinhLuong() << endl;
  97. return out;
  98. }
  99. private:
  100. int SoNgayLam;
  101. };
  102.  
  103.  
  104. void main()
  105. {
  106. system("start https://www.facebook.com/pages/C%C3%B9ng-h%E1%BB%8Dc-l%E1%BA%ADp-tr%C3%ACnh/632038696941833");
  107. NVSanXuat a("nguyen huu tho", "11 07 96", 300000, 1000);
  108. cout << a;
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement