Answer the following statements true (T) or false (F)

1. 6. It is legal to call a constructor as a member function of an object of a class, as in
```
class A
{
public:
A(){}
A(int x, int y):xx(x), yy(y) {}
// other members
private:
int xx;
int yy;
};
int main()
{
A w;
w.A(2,3); // Is this legal?
}
```
2. A constructor can be called implicitly or explicitly. (Implicitly means the compiler did it for you.) In the interest of uniformity in answers, please use class A; for your examples.
3. A class may not have another class type object as a member.
4. Any use of the keyword const is a promise to the compiler, and a request to the compiler to enforce the promise. What promises?


1. False.
You cannot call a constructor as if it were a member function. This writer’s compilers all give an error message that says the equivalent of this remark. The author of this code probably wanted w = A(2,3); which is legal, and does what this fragment appears to do.
2. True
A constructor can be implicitly called with the declaration A x;. The default constructor is called explicitly with syntax is A x = A();
If the declaration is A x(2), the constructor is called implicilty. The equvalent explicit constructor call is A x = A(2); and so on.
3. False
A class type may be treated exactly like any other type. An int can be a member of a class, so can another class be a type of a member of another class.
4. True.
We have seen several uses of const. A const call-by-reference parameter promises not to write code that could change the parameter, hence not to write code that could change the argument.. A const identifier definition promises not to write code that could change the identifier. Finally, a const member function.promises not to write code in the member function that could change the state of the calling object.

Computer Science & Information Technology

You might also like to view...

The file that contains the class function definitions is called the ________________.

A. class specification file B. header file C. main program file D. class implementation file

Computer Science & Information Technology

Buttons start out as ____ that you convert to button symbols.

A. graphics B. movie clips C. text D. any of the above

Computer Science & Information Technology

Using Slideshare, people can find nearby activity partners who share common interests.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

? Critical Thinking Questions Case 4-2 ? Jerry has inherited an Excel sheet that lists all of the system requirements for his team's new project. But unfortunately, his predecessor did not label the requirements with categories-or in some cases failed to categorize them correctly. He needs to take care of this so the requirements can be sorted correctly. ?Jerry has found one system requirement that he thinks could fit into a couple of different categories. The requirement is as follows: An employee record must be added, changed, or deleted only by a member of the human resources department. What is the best categorization of this requirement?

A. ?Performance B. ?Control C. ?Process D. ?Input

Computer Science & Information Technology