In copy constructor definition, if non const values are accepted only ________

In copy constructor definition, if non const values are accepted only ________
A. Only const objects will be accepted
B. Only non – const objects are accepted
C. Only const members will not get copied
D. Compiler generates an error
 
Answer: b
Explanation: Only the non – const objects will be accepted by the compiler. If a const object is passed, the compiler produces an error. To reduce that, we use const argument in definition, so that both const and non – const objects are accepted.
 

Tìm kiếm

Back
Top