This Question is Answered 

    anon

    Differentiate The Constructor And Destructor.

    asked 1 year ago

    Date | Rating

    Answers


    Both of these terms are using in the programming language.Simply the constructor is used for the creation of a variable.While the destructor is used for the destroying of a variable
    Constructer is used for the allocation of memory space for the creation of a variable. The name of the constructer and the class name must be same. The creation of class variable is a difficult and also its initialization is difficult. But with the help of a constructer it can be made easily without the chances of leaving any step.

    The destructor is just used for the destruction of the variable that was created by constructer. The destructor has not any return values and not any arguments. The name of the destructor function will also be the same as the class name. To represent the destructor the negation sign is used at the start of the destructor function. Like (~).
    The destructor function is not used mostly, because when the class variable's working is finished and when it is finished, then automatically the memory which was allocated for that variable, is also free. Destructor is just an extra thing; it is often used for big programs, but very rarely.

    answered 1 year ago

    New Comment

    1000 words left


      Constructor and Destructor are the special kind of Methods of a class in Object Oriented Programming Concept.

      Constructor is called when the class has been initiated (or object is created). The basic use is to intialize the members of the class in that method. Variation of constructor can also be done, you can declare default constructor,having no parameteres, or any number of parameters.

      Destructor is the opposite to constructor. It activated when the class's object has become out of scope or when the function containing this object ends.

      answered 1 year ago

      New Comment

      1000 words left