Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7907469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:27:19+00:00 2026-06-03T11:27:19+00:00

I have a key, and a pointer to left and right nodes defined in

  • 0

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 to BinaryTree::Node *

Any Ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T11:27:20+00:00Added an answer on June 3, 2026 at 11:27 am

    This is your function:

    BinaryTree::Node* BinaryTree::copyHelper(const Node* other) { ...}
    

    It returns a BinaryTree::Node*, and it should be returning a unique_ptr<Node>:

    std::unique_ptr<BinaryTree::Node> BinaryTree::copyHelper(const Node* other) { ...}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay so I have a Binary Search Tree built using only C structs and
Since black red tree is a binary search tree I have decided to use
I have next class and try to declare member function which will return pointer
I am trying to remove the left child (10) of a sample binary search
We've written a smart pointer class and have been using it with great success
What's wrong with the following implementation of a binary search tree (BST) ? I
I have a dictionary that goes like this: typedef struct dictNode { int key;
I have a key generated by SharpSSH in OpenSSH format. How do I convert
I have one key but different values for that key. I tried HashTable but
I am implementing a password reset function and would have the key I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.