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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:39:37+00:00 2026-06-13T18:39:37+00:00

I am getting a few errors that I don’t know about and have spent

  • 0

I am getting a few errors that I don’t know about and have spent entirely to much time pulling my hair out. Here is my Header:

#ifndef MYBSTREE_H
#define MYBSTREE_H

#include "abstractbstree.h"
#include "MyBSTreeFunc.h"
using namespace std;

template<typename T>
class TreeNode
{
  public:
    T m_data;
    TreeNode* m_right;
    TreeNode* m_left;
};

template<typename T>
class MyBSTree:public AbstractBSTree<T>       //LINE 18
{
  private:

    TreeNode<T>* m_root;

  public:


    void MyBSTree();

    int size() const;

    bool isEmpty() const;

    int height() const;

    const T& findMax() const;

    const T& findMin() const;

    int contains(const T& x) const;

    void clear();

    void insert(const T& x);

    void remove(const T& x);

    void printPreOrder() const;

    void printPostOrder() const;

    void print() const;     
};

#endif

And my implementation file:

Line 1-6

void MyBSTree()
{
  m_root -> m_data = NULL;
  m_root -> m_right = NULL;
  m_root -> m_left = NULL;
}

Line 13-21

template<typename T>
bool MyBSTree<T>::isEmpty() const
{
  if (m_root== NULL)
    return true;

  else
    return false;
}

Line 28-35

template < typename T >
const T& MyBSTree<T>::findMax() const
{
  TreeNode* p = m_root;
  while(p -> m_right != NULL)
    p = p -> m_right;
  return p;
}

The error for line 3 in the implementation says ‘m_root’ was not declared in this scope. But it’s cool with lines 4 and 5. I’m guessing because m_data isn’t a pointer? I don’t know.

Next, Line 14, and 21, and quite a few others say that it expected an initializer before the ‘<‘ token. I assume they are all the same issue so I only put a few here.

Finally, it says for line 18 in the header: “template struct MyBSTree redeclared as a different kind of symbol.” It then says Line 1 of my implementation is a previous declaration of ‘void MyBSTree”. I am assuming those go together.

Thanks for all the help.

  • 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-13T18:39:39+00:00Added an answer on June 13, 2026 at 6:39 pm

    You need to fix your constructor declaration:

    template < typename T >
    classMyBSTree
    {
      ... // some stuff
    public:
      MyBSTree(); // no return type
      ... // some stuff
    };
    

    You alse need to fix your constructor:

    template < typename T >
    MyBSTree::MyBSTree() // proper ctor definition
    {
      m_root -> m_data = T(); // use the initializer for that data type
      m_root -> m_right = NULL;
      m_root -> m_left = NULL;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Spent a good few hours on this now and don't seem to be getting
I'm getting a few Don't make functions within a loop. errors from JSLint, anyone
I have had a few problems getting this right, so I wanted to ask
I have few jar files which I am not getting from any repositories.I have
I'm currently getting to know Java and OSGi, so I've read a few books.
I have been roaming the internet for a solution I really don't know what
I'm getting a few errors just after I updated my working copy via SVN.
I have a project that I have been working on for a few days
I'm getting started with making few redirect with .htaccess but I just made something
few days ago i read tutorial about GenericRepository and Unit Of Work patterns http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application

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.