2
Reply

What is Constructor?

Raj Kumar M

Raj Kumar M

Jun 14, 2008
5.5k
0

    A construcor is a method that returns nothing, It is used to instanciate an object and also helps us to perform some tasks exactly when the object is instanciated example: class MyClass { //no constructor ............... } When I want instanciate an object I can't example: MyClass object = new ? class MyClass { MyClass() {MessageBox("Hi I'm MyClass instance")} } MyClass object = new MyClass() When I execute the program the first think done is to display message "Hi I'm MyClass instance"

    Bechir Bejaoui
    June 15, 2008
    0

    When we create instance of class a special method of that class, called that is constructor. Similarly, when the class is destroyed, the destructor method is called. These are general terms and usually not the actual member names in most object-oriented languages. It is initialized using the keyword New, and is destroyed using the keyword Finalize

    Raj Kumar M
    June 14, 2008
    0