Phr0zen_Penguin

The Reloaded Destructor

Oct 15th, 2014
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.77 KB | None | 0 0
  1. /*==================================================================================================
  2.   --------------------------------------------------------------------------------------------------
  3.   [stackPhuke.cpp]
  4.   Stack phuck + nuke: It's fun time!
  5.  
  6.   NOTE:
  7.   You have more fun if you compile with GCC.  Meanwhile, check out the exponential compile time.
  8.  
  9.         (c) Damion 'Phr0z3n.dev' Tapper, 2014.
  10.         Email: [email protected]
  11.   --------------------------------------------------------------------------------------------------
  12.   ==================================================================================================*/
  13. #include <iostream>
  14.  
  15. /*===============================================--=================================================
  16.                                             THE CTemp CLASS
  17.   --------------------------------------------------------------------------------------------------*/
  18. class CTemp
  19. {
  20.     public:
  21.         CTemp(){ std::cout << "CTemp constructor." << std::endl; }
  22.         CTemp(CTemp *pct)
  23.         {
  24.             CTemp *pctemp(pct);
  25.  
  26.             std::cout << "CTemp overloaded constructor." << std::endl;
  27.         }   // "I am the architect."
  28.         ~CTemp();
  29. };
  30.  
  31. CTemp   *pctemp;
  32.  
  33. CTemp::~CTemp()
  34. {
  35.     try
  36.     {
  37.         std::cout << "CTemp destructor exception thrown." << std::endl;
  38.  
  39.         throw(pctemp);
  40.     }
  41.     catch(CTemp *cte)
  42.     {
  43.         CTemp   ctempe(cte);
  44.  
  45.         std::cout << "CTemp destructor exception caught." << std::endl;
  46.     }
  47. }
  48.  
  49. /*===============================================--=================================================
  50.                                             THE main METHOD
  51.   --------------------------------------------------------------------------------------------------*/
  52. int main(void)
  53. {
  54.     /**
  55.      *
  56.      **/
  57.     CTemp   pct(new CTemp);
  58.  
  59.     pctemp = &pct;
  60.  
  61.     delete pctemp;
  62.     //pctemp->~CTemp();
  63.     //pct.~CTemp();
  64.  
  65.     return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment