Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 43_Deconstructors
- #include "VeryBest.h"
- #include <iostream>
- using namespace std;
- int main()
- {
- VeryBest myObject;//constructor runs
- cout<<"OMG what a pussy!!"<<endl;
- return 0;
- }//when you get here C++ automatically destroys all your object's (this case VeryBest)
- //destructor - the code that runs automatically (not explicitly ) upon the destruction of your object.
- //there is no deconstruction overloading
- //when your program finish running that's when your deconstruction gonna get called/
- //it's gonna called automatically
- //------------------------------------------------------------------------------------
- #ifndef VERYBEST_H
- #define VERYBEST_H
- class VeryBest
- {
- public:
- VeryBest();
- ~VeryBest();
- };
- #endif // VERYBEST_H
- //------------------------------------------------------------------------------------
- #include "VeryBest.h"
- #include <iostream>
- using namespace std;
- VeryBest::VeryBest()
- {
- cout<<"I'am the constructor"<<endl;
- }
- VeryBest::~VeryBest(){
- cout<<"Oh fuck, this is pussy destroyer!!!";
- }
Advertisement
Add Comment
Please, Sign In to add comment