Jump to content




Recent Status Updates

  • Photo
      15 Sep
    Error

    Programming is something that I enjoy and want to make a career out of. But, I usually tend to start things and not finish them. Any advice on how I can finish what I start?

    Show comments (2)
  • Photo
      12 Sep
    FacetiousTurtle33

    Just joined. Really enjoy this sight. Excited to become a great programmer, and helper.

    Show comments (3)
View All Updates

Developed by Kemal Taskin
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
  • 17,046 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/