I have a key, and a pointer to left and right nodes defined in a struct, in a class for a binary search tree.
I was getting parasoft errors within the copy helper function of the class, so was advised to change the code to:
BinaryTree::Node* BinaryTree::copyHelper(const Node* other)
{
if(other == NULL)
{
return NULL; // If there's no Node to copy, return NULL.
}
else
{
//Node* newNode = new Node;
typedef std::unique_ptr<Node> NodePtr;
NodePtr newNode(new Node);
if(newNode)
{
newNode->name = other->name;
newNode->left = copyHelper(other->left);
newNode->right = copyHelper(other->right);
}
return newNode;
}
}
Now I am getting an error on the return statement of the newNode:
IntelliSense: no suitable conversion function from
NodePtr
toBinaryTree::Node *
Any Ideas?