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 Cisco IOS command is used to configure the VTP mode on a switch?

A) virtual mode mode B) vtp mode mode C) server mode mode D) vlan server mode

Computer Science & Information Technology

Briefly explain how bottom-up and top-down design approaches can be carried out using Rhino.

What will be an ideal response?

Computer Science & Information Technology