A copy constructor is invoked when an object is returned by value from a function, as a temporary object is created and copied to the caller. While passing by value also invokes a copy constructor, returning by value is a classic scenario where this occurs.