Forum

Destructor And Constructor

This thread contains 1 reply, has 2 voices, and was last updated by Nitesh User Do not delete 6 years, 2 months ago.

  • Author Replies
    • #53004

      What is a Destructor and Constructor?


    • #53046

      Destructor:

      A destructor is a member function which destructs or deletes an object.

      When is destructor called?

      A destructor function is called automatically when the object leaves scope:

      (1) the function ends
      (2) the program ends
      (3) a block containing local variables ends
      (4) a delete operator is called

      Guidelines of destructor:

      1) Destructors have the same name from the class gone before by a tilde (~)
      2) Destructors don’t take any argument and don’t return anything.

      Constructor:

      1) A constructor is an uncommon type of member function that introduces an object automatically when it is created.

      2) The compiler identifies a given member function is a constructor by its name and the return type.

      3) A constructor has the same name from that of the class and it doesn’t have any return type.


      Regards,
      Nitesh Bavishiya

Viewing 1 reply thread

You must be to reply to this thread.Please or . Registration is 100% free.

GET FREE CONSULTATION

Call Us Now For Free Consultation97370 05566

Our experts listen to you patiently and suggest you the right course after conducting a personality profile test. Register your interest below to schedule personality profile test for you.

SUBSCRIBE TO OUR NEWSLETTER

Subscribe to get latest updates regarding courses, IT industry and career prospects.

Copyright 2016-2025 Smart Mentors. All Rights Reserved.

Login

FORGOT PASSWORD

Sign up now to Become An Instructor

    Register your Interest

      cf7captchaRegenerate Captcha