edited by
2,720 views
0 votes
0 votes

Which of the following is true of constructor function in C++ ?

  1. A class must have at least one constructor.

  2. A constructor is a unique function which cannot be overloaded.

  3. A constructor function must be invoked with the object name.

  4. A constructor function is automatically invoked when an object is created.

edited by

1 Answer

0 votes
0 votes

Answer: (D)

Whenever we instantiate a class, i.e., create an object of a class, a default constructor, which has same name as that of a class, is automatically invoked. 

So, even if we don't have a constructor in our class, a default constructor is invoked automatically during instantiation. Hence, (A) is incorrect.

Constructors may be overloaded, same as functions. Hence, (B) is incorrect.

Constructors are invoked with the same name as that of the class. Hence, (C) is incorrect.

Related questions

2 votes
2 votes
1 answer
2
1 votes
1 votes
2 answers
3
go_editor asked Mar 28, 2020
1,254 views
The number of edges in a complete graph with $‘n’$ vertices is equal to :$n(n-1)$$\large\frac{n(n-1)}{2}$$n^2$$2n-1$
0 votes
0 votes
1 answer
4
go_editor asked Mar 28, 2020
560 views
A context free grammar is :type $0$type $1$type $2$type $3$