QuesAns Print Page – CSKC
Sign In

Search

siteicon
Q&A ICSE2017-03E #7239

Question:

Differentiate between constructor and function.

Answer:

The constructor of a class is invoked automatically during object creation while a function is invoked manually after object creation.
A constructor is invoked only once while a function can be invoked multiple times.
A constructor has the same name as the class in which it is defined while a function can have any name.