I'm reading an article in 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 question is in the ProcessLargeObject
function. Does the passage necessarily have to be by reference? And if the function ProcessLargeObject
had the following signature ProcessLargeObject(LargeObject *lo)
what would be the difference?