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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:21:45+00:00 2026-06-02T14:21:45+00:00

For my Data Structures class we’ve been asked to take a previously implemented balanced

  • 0

For my Data Structures class we’ve been asked to take a previously implemented balanced tree(from a prior project) and use it to implement parts of the C++ standard map class.

http://cplusplus.com/reference/stl/map/

I figured the most obvious first step was to template the entire class, allowing for separate key and storage types. Of course, I ran into problems with templating. Generally my templating works until I attempt to template a function that is using a local nested datatype “rbNode”. If I include template parameters in the function definition, I get syntax errors. If I leave them out, I get “template parameters not included” errors.

This is the class implementation that gives me the errors in Visual Studio 2010 (errors listed below):

#include <cstdlib>
#include <iostream>
template <class key_type, class T>
class myMap
{
private:
    //typedef pair<const key_type, T> value_type;
    struct rbNode
    {
        //value_type ref;
        int element;
        rbNode * left;
        rbNode * right;
        bool red;
        rbNode(int key)
        {
            left = NULL;
            right = NULL;
            //ref.first = key;
            //ref.second = element;
            element = key;
            red = true;
        }
    };
    rbNode * root;
    bool search(int , rbNode *);
    rbNode * LL_Rotation(rbNode *);
};

template <class key_type, class T>
myMap<key_type,T>::rbNode* myMap<key_type,T>::LL_Rotation(rbNode * curr) // errors occur on this line
{
    rbNode * temp = curr->right;
    curr->right = temp->left;
    temp->left = curr;

    curr->red = 1;
    temp->red = 0;

    return temp;
}

This function, however, compiles just fine with the above function commented out:

template <class key_type,class T> 
bool myMap<key_type,T>::search(int key,rbNode * tree)
{
    if(tree!=NULL)
        if(tree->element==key)
            return true;
        else
            if(key< tree->element)
                return search(key,tree->left);
            else
                return search(key,tree->right);
    else
        return false;
}

In particular, I’m getting

missing ';' before '*'
and
missing type specifier - int assumed. Note: C++ does not support default-int
on the line the implementation for “LLRotation”‘s name is in (pointed out in comment). I’m not very experienced with templating, so I get the feeling the I’m making a very stupid mistake. Regardless, if you need more of my code, or more information, let me know. Any help is greatly appreciated.

Note: I’m sure my code has plenty of bad practices, etc. in it. I’m still learning. Feel free to point them out, but I’m mostly concerned with the templating issues.

  • 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-02T14:21:46+00:00Added an answer on June 2, 2026 at 2:21 pm

    You’re just missing a typename for the dependent name:

    template <class key_type, class T>
    typename myMap<key_type,T>::rbNode* myMap<key_type,T>::LL_Rotation(rbNode * curr)
    ^^^^^^^^
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my data structures class, we've been assigned a project in which we are
I want to store some data from structures like this: class Project { ChildA
In the data structures class that I am currently taking, we have been tasked
I have a project for my Data Structures class, which is a file compressor
I'm doing an assignment for my Data Structures class. we were asked to to
For my Algorithms & Data Structures class, I've been tasked with implementing a splay
My data structures class is working with trees. We are implementing a 3-ary tree,
For my Advanced Algorithms and Data Structures class, my professor asked us to pick
I'm working on a project for a data structures class. The goal is to
It's been a while since my data structures class and I'm having a hard

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.