Suppose you have a class whose objects are very, very large. Briefly, describe the advantages and drawbacks of call-by-value and call-by-reference for large objects. Describe a parameter passing mechanism that will allow the safety of call-by-value and the efficiency of call-by-reference.

What will be an ideal response?


Call-by-value protects the caller’s copy of the data from change. However, significant
memory space must be used for the copy in the value parameter and copying data
takes time. Call-by-reference endangers the caller’s data.
The required mechanism uses a const call-by-reference parameter.

Example:
```
class A{/* stuff */};
void foo(const A& arg);
```

Const reference will provide protection against inadvertent change in the caller’s
argument. The compiler will refuse to compile any code that makes the parameter an
l-value.

Computer Science & Information Technology

You might also like to view...

Which of the following is true?

A) A TreeSet created with the no-arg constructor expects its elements to implement the Comparable interface B) A TreeSet created with the no-arg constructor expects its elements to implement the Comparator interface C) The load factor of TreeSet should never exceed 50% to ensure maximum performance D) The load factor of TreeSet should never exceed 75% to ensure maximum performance

Computer Science & Information Technology

What does the setfacl -b command do??

A. ?It removes all extra ACL assignments on a given file B. ?It sets 7777 on a given file or folder for all users / groups C. ?The file's user / group ownership is changed to to root / root D. ?The file's ACL assignments are created and are then ready to be modified.

Computer Science & Information Technology

The ____________________ is used in conjunction with the Layers panel to create animation frames.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

You can see the properties for a CSS rule by looking at the ____________________.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology