0
I am reading an article on msdn about smart pointers. In the article there is this example:
class LargeObject
{
public:
void DoSomething(){}
};
void ProcessLargeObject(const LargeObject& lo){}
void SmartPointerDemo()
{
// Create the object and pass it to a smart pointer
std::unique_ptr<LargeObject> pLarge(new LargeObject());
//Call a method on the object
pLarge->DoSomething();
// Pass a reference to a method.
ProcessLargeObject(*pLarge);
} //pLarge is deleted automatically when function block goes out of scope.
My doubt is in the function ProcessLargeObject
. Must the passage be by reference? What if the function ProcessLargeObject
had the following signature ProcessLargeObject(LargeObject *lo)
what would be the difference?