Advertisement
huutho_96

OOP Vui

Dec 23rd, 2015
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. //https://www.facebook.com/CungHocLapTrinhUIT/
  2. //Đoạn code 1
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. class A{
  7. public:
  8.     A(){
  9.         cout << "Constructor A" << endl;
  10.     }
  11.     ~A(){
  12.         cout << "~Destructor A" << endl;
  13.     }
  14. };
  15.  
  16. class B : public A
  17. {
  18. public:
  19.     B(A &a){
  20.         cout << "Constructor B" << endl;
  21.     }
  22.     ~B(){
  23.         cout << "~Destructor B" << endl;
  24.     }
  25. };
  26.  
  27. void main(){
  28.     A a;
  29.     B b(a);
  30. }
  31.  
  32. //Đoạn code 2
  33. #include <iostream>
  34. using namespace std;
  35.  
  36. class A{
  37. public:
  38.     A(){
  39.         cout << "Constructor A" << endl;
  40.     }
  41.     ~A(){
  42.         cout << "~Destructor A" << endl;
  43.     }
  44. };
  45.  
  46. class B : public A
  47. {
  48. public:
  49.     B(A a){
  50.         cout << "Constructor B" << endl;
  51.     }
  52.     ~B(){
  53.         cout << "~Destructor B" << endl;
  54.     }
  55. };
  56.  
  57. void main(){
  58.     A a;
  59.     B b(a);
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement