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 7956907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:08:11+00:00 2026-06-04T04:08:11+00:00

When I add a Retreive() method to my BST implementation I get a unresolved

  • 0

When I add a Retreive() method to my BST implementation I get a “unresolved external” compiler error.Compile Error

The Retrieve() member function checks to see whether the value entered by the user exists in the BST, and if it does sets found = false.

//Header File
using namespace std;

struct PersonRec
{
    char name[20];
    int bribe;
    PersonRec* leftLink;
    PersonRec* rightLink;
};


class CTree
{

private:
    PersonRec *tree;
    bool IsEmpty();
    void AddItem( PersonRec*&, PersonRec*);
    void DisplayTree(PersonRec*);
    void Retrieve(PersonRec*, PersonRec*,bool&);

public:
    CTree();
    //~CTree();
    void Add();
    void View();

};




//Implementation File
#include <iostream>
#include <string>

using namespace std;

#include "ctree.h"

CTree::CTree()
{
    tree = NULL;
}

//PersonList::~MyTree()
//{
//
//}


bool CTree::IsEmpty()
{
    if(tree == NULL) 
    {
        return true;
    }
    else
    {
        return false;
    }
}

void CTree::Add()
{
    PersonRec* newPerson = new PersonRec();
    cout << "Enter the person's name: ";
    std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
    cin.getline(newPerson->name, 20);
    cout << "Enter the person's contribution: ";
    cin >> newPerson->bribe;
    bool found = false;


    newPerson->leftLink = NULL;
    newPerson->rightLink = NULL;

    Retrieve(tree, newPerson, found);
     if (found)
         cout << "Bribe allready entered\n";
     else
         AddItem(tree, newPerson);
}

void CTree::View()
{
    if (IsEmpty())
    {
        cout<<"The list is empy";
    }
    else
    {
        DisplayTree(tree);

    }

};

void CTree::AddItem( PersonRec*& ptr, PersonRec* newPer )
{
        if (ptr == NULL)
        {
            ptr = newPer;
        }
        else if ( newPer->bribe < ptr->bribe)
            AddItem(ptr->leftLink, newPer); 
        else
            AddItem(ptr->rightLink, newPer); 
}
void CTree::DisplayTree(PersonRec* ptr)
{
    if (ptr == NULL)
                    return;
    DisplayTree(ptr->rightLink);
    cout<<ptr->name<<" "<<"$"<<ptr->bribe <<endl;
    DisplayTree(ptr->leftLink); 
}
void Retrieve(PersonRec*& ptr, PersonRec* newPer, bool& found)
{
    {
        if (ptr == NULL)
        {
            found = false; // item is not found.
        }
        else if ( newPer->bribe < ptr->bribe)
        {
            Retrieve(ptr->leftLink, newPer, found);
        }
             // Search left subtree.
        else if (newPer->bribe > ptr->bribe)
        {
            Retrieve(ptr->rightLink, newPer, found);// Search right subtree.
        }   
        else
        {
            //newPer.bribe = ptr->info; // item is found.
            found = true;
        }
    }
}
//Driver File
#include <iostream>

using namespace std;
#include <cstdlib>
#include "ctree.h"

int displayMenu (void);
void processChoice(int, CTree&);

int main (void)
{
int num;
CTree ct;
do 
{
num = displayMenu();
if (num != 3)
processChoice(num, ct);
} while (num != 3);
return 0;
}

int displayMenu (void)
{
int choice;
cout << "\nMenu\n";
cout << "==============================\n\n";
cout << "1. Add student to waiting list\n";
cout << "2. View waiting list\n";
cout << "3. Exit program\n\n";
cout << "Please enter choice: ";
cin >> choice;
return choice;
}

void processChoice(int choice, CTree& myTree)
{
   switch (choice)
   {
      case 1: myTree.Add (); break;
      case 2: myTree.View (); break;
   } 
}
  • 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-04T04:08:13+00:00Added an answer on June 4, 2026 at 4:08 am

    You don’t qualify the definition with the class name:

    void Retrieve(PersonRec*& ptr, PersonRec* newPer, bool& found)
    

    should be

    void CTree::Retrieve(PersonRec* ptr, PersonRec* newPer, bool& found)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am struggling to retrieve custom attributes from a method. As you can see,
I'm working on an object-oriented Excel add-in to retrieve information from our ERP system's
I have a grid view and I add columns to it by code: //Retrieve
i have that method that retrieve the removable devices information which are NTFS :
I want to retreive at the finaly of call recursive method, a set of
When using a Delegate, I can use Delegate.GetInvocationList() Method to retrieve the invocation list
I have this function to retreive response cookies in a CookieContainer (this.cookies) private void
I'm using ajax to retrieve some data from the backend. I get the result
I use the following method to retrieve something from a webservice using a HTTPWebRequest:
I use this code to retrieve JSON details from php call and I add

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.