Jump to content

Check out our Community Blogs

Recent Status Updates

  • Photo
      10 Jul

    True or just funny? One day programmers will become obsolete as they make errors and programs don't :D

    Show comments (4)
View All Updates

Developed by TechBiz Xccelerator
- - - - -

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 WingedPanther73


    A spammer's worst nightmare

  • Moderator
  • 17757 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/