Jump to content

Recent Topics

Recent Status Updates

  • Photo
      18 Aug

    When faced with a wall of errors and no hope to fix them, remember the following "Programs always do what you tell them to, and seldom what you want them to, but eventually you'll run out of things that can go wrong and it'll just work. and that's the secret to good programming."

    Show comments (2)
View All Updates

Developed by Kemal Taskin
- - - - -

destructors overloading?

  • Please log in to reply
3 replies to this topic

#1 ahmed


    CC Addict

  • Senior Member
  • PipPipPipPipPip
  • 308 posts

Posted 30 March 2009 - 07:03 AM

I wanted to know that why cant we overload a destructor?I have searched on Google but haven't found any reason why it cant be . And another questions is that why is destructor not public,private or protected?
  • 0

#2 MerakSpielman


    CC Regular

  • Just Joined
  • PipPipPip
  • 44 posts

Posted 30 March 2009 - 07:51 AM

My understanding is that you can't overload a destructor because you don't call them, and thus don't pass them any variables. They simply happen automatically when you delete an object. They're best used for cleanup work, so you can free up any memory you reserved in the object.

What are you trying to do where you want to pass variables to your destructor?
  • 0

#3 ahmed


    CC Addict

  • Senior Member
  • PipPipPipPipPip
  • 308 posts

Posted 30 March 2009 - 08:40 AM

i just wanted to know the reason I also know that u cant pass them any variables but i wanted the reasons , need more answers :)
  • 0

#4 WingedPanther


    A spammer's worst nightmare

  • Moderator
  • 17,004 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 30 March 2009 - 01:29 PM

A destructor is called by the object going out of scope or the delete function being called on it. There is no function call for parameters to be passed through.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/