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
Correct responses are: a) c) d) e)
Explanation: 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.
You might also like to view...
Linux is a best described as a(n) ________ kernel.
a) monolithic b) layered c) micro d) exo
____________________ are words that relate to the content of the website.
Fill in the blank(s) with the appropriate word(s).