Which of the following is correct regarding presence and behavior of constructor is correct. Assume that the class name is C.

a) To use the declaration, C x; requires a default constructor must be present.
b) To invoke the default constructor, the syntax must be C x();
c) A constructor is called automatically when you declare an object of class type, but
any constructor can be called after declaration to set all the member variables to a
known state.
d) An explicit call to a constructor creates an anonymous object, which can be
assigned.
e) In spite of the fact that a constructor appears to be a member function, a
constructor may not be called as if it were a member function

a) To use the declaration, C x; requires a default constructor must be present. , c) A constructor is called automatically when you declare an object of class type, but
any constructor can be called after declaration to set all the member variables to a
known state. , d) An explicit call to a constructor creates an anonymous object, which can be
assigned. , and e) In spite of the fact that a constructor appears to be a member function, a
constructor may not be called as if it were a member function

b) defines a function that takes no arguments and returns class C object.
Part c) is right as far as it goes. It should mention that the constructor may not be
called as if it were a member function; rather, it must be called to generate an
anonymous object, which is assigned to change the state of an object.

Computer Science & Information Technology

You might also like to view...

In macOS, the ____ fork typically contains data the user creates.

a. data b. content c. user d. resource

Computer Science & Information Technology

A laser printer is displaying a message indicating a maintenance kit is due for replacement. Which of the following will be a part of the replacement process?

A. Clean the heating element.
B. Reset the page counter.
C. Replace the print ribbon.
D. Replace the print head.

Computer Science & Information Technology