Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://www.facebook.com/CungHocLapTrinhUIT/
- //Đoạn code 1
- #include <iostream>
- using namespace std;
- class A{
- public:
- A(){
- cout << "Constructor A" << endl;
- }
- ~A(){
- cout << "~Destructor A" << endl;
- }
- };
- class B : public A
- {
- public:
- B(A &a){
- cout << "Constructor B" << endl;
- }
- ~B(){
- cout << "~Destructor B" << endl;
- }
- };
- void main(){
- A a;
- B b(a);
- }
- //Đoạn code 2
- #include <iostream>
- using namespace std;
- class A{
- public:
- A(){
- cout << "Constructor A" << endl;
- }
- ~A(){
- cout << "~Destructor A" << endl;
- }
- };
- class B : public A
- {
- public:
- B(A a){
- cout << "Constructor B" << endl;
- }
- ~B(){
- cout << "~Destructor B" << endl;
- }
- };
- void main(){
- A a;
- B b(a);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement