Chapter 14: Problem 25
Why is a class's copy constructor called when an object of that class is passed by value into a function?
Short Answer
Expert verified
Answer: A class's copy constructor is called when an object is passed by value into a function because the function needs to create a new local object and initialize it with the same data as the original object. The copy constructor is called to perform the correct data copying process from the original object to the new local object in the function. This ensures that the function operates on a separate copy of the data without modifying the original object outside the function's scope.