Difference between member function and a constructor?

Constructor cannot return value

Showing Answers 1 - 4 of 4 Answers

amitmathur

  • Feb 27th, 2010
 

Constructors get automatically invoked when its class object is created; whereas method has to be explicitly called.

Constructors need to be have the same name whereas function need not to be the same.

There is no return type given in a constructor signature (header). The value is this object itself so there is no need to indicate a return value.

There is no return statement in the body of the constructor.

The first line of a constructor must either be a call on another constructor in the same class (using this), or a call on the superclass constructor (using super). If the first line is neither of there, the compiler automatically inserts a call to the parameterless super class constructor.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions