C++ Programming - OOPS Concepts - Discussion

Discussion Forum : OOPS Concepts - General Questions (Q.No. 28)
28.
Which of the following functions are performed by a constructor?
Construct a new class
Construct a new object
Construct a new function
Initialize objects
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
12 comments Page 1 of 2.

Xyz said:   1 decade ago
Every Class should define it's own Constructor.

Tushar Bhimarao Dongare said:   1 decade ago
Constructor it is a special member function it is used to initialize object of class.

Sachin Shinde said:   1 decade ago
Constructor initializes objects of class, if programmer(we) don't write default constructor then compiler will provide.

Ranjan Kumar Mishra said:   1 decade ago
After declaration of object a default constructor internally call by compiler if we don't create any parameterized object and constructor which initializes the object.

Vimalesh valiya said:   1 decade ago
Constructor jobs are to do the following:

[B] Construct a new object.
[D] Initialize objects.

Both Option B and Option D are valid and correct.

Deepa t.s said:   1 decade ago
Constructor it is a special member function, called automatically during object creation.

Niteen said:   10 years ago
@Vimalesh Valiya : That's correct both options are right.

Peter said:   10 years ago
Indeed, there should be option E/ saying both B and D are valid. + may be even F/ claiming all are correct, or A, B, C to provide some distraction for those who are unsure.

But the Q as it stands now is distracting those, who know, and answer D is not sufficient. Constructor initializes default values, but according to best practice methods, those are init (param) functions, that should initialize state of object to wanted values.

Vikram Ajabe said:   8 years ago
Constructor is used to the initialising state of the object. Constructor is invoked at the time of object creation.

Cool SAM said:   8 years ago
Give me the Proper definition of the constructor.


Post your comments here:

Your comments will be displayed after verification.