Is there any good practice or rule on how to use the QSharedPointer object as a method parameter or method return value?
By value:
LMNode::setParent(QSharedPointer<LMNode> parent) { this->parent = parent; } QSharedPointer<LMNode> LMNode::getParent() { return this->parent; }
or better at the link:
LMNode::setParent(const QSharedPointer<LMNode>& parent) { this->parent = parent; } const QSharedPointer<LMNode>& LMNode::getParent() { return this->parent; }
Of course, in the second version, I avoid incrementing the reference count and changing the QSharedPointer object. But is there a strict way how should I do?
source share