The Gateway to Computer Science Excellence
0 votes
200 views

A copy constructor is invoked when:

(A) a function returns by value        

(B) an argument is passed by value

(C) a function returns by reference 

(D) none of the above

in Object Oriented Programming by Loyal (7.3k points)
recategorized by | 200 views
0
Is it option d) ?

1 Answer

0 votes
Best answer
In C++, a Copy Constructor may be called in following cases:
1. When an object of the class is returned by value.
2. When an object of the class is passed (to a function) by value as an argument.
3. When an object is constructed based on another object of the same class.
4. When compiler generates a temporary object.

 

Hence, ans B
by Loyal (7.3k points)
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,322 answers
198,402 comments
105,159 users