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

  • Home
  • SEARCH
  • 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 64745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:50:17+00:00 2026-05-10T18:50:17+00:00

template <class T> bool BST<T>::search(const T& x, int& len) const { return search(BT<T>::root, x);

  • 0
template <class T> bool BST<T>::search(const T& x, int& len) const {     return search(BT<T>::root, x); }   template <class T> bool BST<T>::search(struct Node<T>*& root, const T& x) {    if (root == NULL)        return false;    else       {          if (root->data == x)              return true;          else if(root->data < x)              search(root->left, x);          else               search(root->right, x);                        }              } 

So this is my search function for my BST class with a T node. x is the data being searched for within the tree, len is just the amount of nodes it has to travel to come up with the matching node if it exists. I have not implented that yet, I’m just incrementally developing my assignment. I’m calling it by doing this:

if(t.search(v[1], len) == true)        cout << endl << 'true'; 

v is just a vector I had to create to compare it to, and so this is just supplying it with an int. The error I’m getting:

BST.h: In member function âbool BST<T>::search(const T&, int&) const [with T = int]â: prog5.cc:24:   instantiated from here     BST.h:78: error: no matching function for call to âBST<int>::search(Node<int>* const&, const int&) constâ     BST.h:76: note: candidates are: bool BST<T>::search(const T&, int&) const [with T = int] BST.h:83: note:                 bool BST<T>::search(Node<T>*&, const T&) [with T = int] 

So I’m not sure what I’m doing wrong or where I’m doing wrong.

  • 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. 2026-05-10T18:50:17+00:00Added an answer on May 10, 2026 at 6:50 pm

    Okay, bool BST<T>::search(struct Node<T>*& root, const T& x) should probably have const after it like so: bool BST<T>::search(struct Node<T>*& root, const T& x) const. Basically, you’ve called a non-const function from a const function and this is a no-no.

    BTW, this looks suspect to me ‘struct Node<T>*&‘… I’d probably drop the & and work with Node<T>*… but maybe you need that because of the struct?

    Also, this is C++, there is no reason to leave Node as a struct… needing to have struct in the parameter definition just looks bad, IMHO. Why not make Node a class?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 67k
  • Answers 67k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I think it's supposed to be: g++ *.o -L. -lboost_regex-gcc… May 11, 2026 at 11:53 am
  • added an answer Writeln is what we call a compiler 'magic' function. If… May 11, 2026 at 11:53 am
  • added an answer It turns out to get this application working under VBScript,… May 11, 2026 at 11:53 am

Related Questions

template <class T> bool BST<T>::search(const T& x, int& len) const { return search(BT<T>::root, x);
template <class T> void BT<T>::inOrder(void (*inOrderPtr)(T&)) { inOrderPtr(inOrder(this->root)); } template <class T> void BT<T>::inOrder(Node<T>*
I have a template class for thread-safe vector: template <class T> class SharedVector {
Suppose I have code like this: template<class T, T initial_t> class Bar { //
I have a templated class defined (in part) as template <class T> MyClass {
Assume I have a function template like this: template<class T> inline void doStuff(T* arr)
Below are lines from the c++ programming language template<class T > T sqrt(T );
What does the class part of a template statement do? Example: template <class T>
In visual C++, I can do things like this: template <class T> class A{
Let's say we have a class, MyParent: class MyParent { public: template<namespace T> MyParent()

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.