asked 176k views
3 votes
A constructor cannot

be overloaded.
initialize variables to their defaults.
specify return types or return values.
have the same name as the class.

1 Answer

1 vote

Answer:

The correct answer for the given question is " specify return types or return values".

Step-by-step explanation:

Constructor are used to initialize the object of a class that means they initialize variables of a class.

Following are the properties of constructor

1.Constructor name have the same name as the class name

2.Constuctor cannot have ruturntype not even void this means constructor cannot return value.

3.Constructor are automatic called when object are created.

Following are the example of constructor

class abc

{

public:

abc() // default constructor

{

cout<<"hiii ";

}

};

void main() // main method()

{

abc ob;// object created constructor called it print hii

}

Output:

hiii

answered
User Dominic Green
by
8.1k points