Machine-translated by Google. Questions are authored in English.
Top

Discussion

Function declaration gives the name of the function. Which of the following statements are relevant for function :

(i) The semantics of argument passing are identical to semantics of initialisation.
(ii) The argument types are checked and implicit argument type conversion takes place when necessary.
(iii) The argument types are unchecked and explicit argument type conversion takes place when necessary.
(iv) A function declaration may contain argument names

  • A.(i) and (ii)
  • B.(i), (ii) and (iv)
  • C.(i), (ii) and (iii)
  • D.(ii) and (iv)

Answer: B

The answer is (i), (ii) and (iv).

These follow Stroustrup's description of C++ functions. Argument passing has the same semantics as initialisation (i); the types of arguments are checked against the declaration and implicit conversions are applied where needed (ii); and a declaration may include argument names, though the compiler ignores them (iv).

Statement (iii) is the opposite of (ii): arguments are not unchecked, and conversions are implicit, not explicit. So any option including (iii) is wrong, and (i) and (ii) or (ii) and (iv) alone leave out a true statement.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.