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...
The ____ gallery has a wide variety of preset formatting combinations for coloring pictures.
A. Color B. Design C. Style D. Format
Glasses are a wearable technology that has a tiny computer display visible to both eyes
Indicate whether the statement is true or false
The mysql_close() function is used to explicitly close a database connection.
Answer the following statement true (T) or false (F)
Line 5 in the function below can be replaced with ____. 1 void strcopy (char string1[], char string2[]) 2 { 3 int i = 0; 4 5 while (string2[i] != '\0') 6 { 7 string1[i] = string2[i]; 8 i++; 9 }10 string1[i] = '\0';11 }
A. while (string2[i]) B. while (!string2[i]) C. while (string2[i] < '\0') D. while (string2[i] != '\n')