Jump to content





Recent Status Updates

  • Photo
      16 Apr
    Kadence

    If you're reading this, you're on my profile and I know you're on my profile because I'm probably viewing yours.

    Show comments (6)
  • Photo
      10 Apr
    Poe

    Finally (and hopefully) i'm getting a team together that knows a little of this and a little of that; and maybe all my open source projects that are half written can begin to be released. :)

View All Updates
Photo
- - - - -

destructors overloading?


  • Please log in to reply
3 replies to this topic

#1 ahmed

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

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

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

WingedPanther

    A spammer's worst nightmare

  • Moderator
  • 16,619 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