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

The Archive Base Latest Questions

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

I have already searched SO and google, I am not declaring the same variable

  • 0

I have already searched SO and google, I am not declaring the same variable in two places nor am I including something in a weird way..that I know of. The insert method should be working fine, it’s a pre-written method(i guess that could be wrong too.. lol). This is the error I get.

Error:

error C2872: 'range_error' : ambiguous symbol
........ while compiling class template member function 'Error_code List<List_entry>::insert(int,const List_entry &)'

To me the insert method looks alright, I don’t see any problems with the position variable which is being compared to 0 or count which is declared as 0 in the constructor to return the range_error.

Insert Method:

template <class List_entry>
Error_code List<List_entry>::insert(int position, const List_entry &x){
    Node<List_entry> *new_node, *following, *preceding;
    if(position < 0 || position > count){
        return range_error;
    }
    if(position == 0){
        if(count == 0) following = nullptr;
        else {
            set_position(0);
            following = current;
        }
        preceding = nullptr;
    }
    else {
        set_position(position - 1);
        preceding = current;
        following = preceding->next;
    }

    new_node = new Node<List_entry>(x, preceding, following);

    if(new_node == nullptr) return overflow;
    if(preceding != nullptr) preceding->next = new_node;
    if(following != nullptr) following->back = new_node;

    current = new_node;
    current_position = position;
    count++;

    return success;
}

Could the problem be in that I don’t have an implementation of the overloaded = operator?

All code here: pastie.org/1258159

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

    range_error is defined both in your code (in the global namespace) and by the Standard Library (in the std namespace). Your use of using namespace std; to drag the entire Standard namespace into the global namespace creates an ambiguity. You should do at least one of the following:

    • remove using namespace std from the global namespace; either use the namespace within your functions, or use just the names you need, or qualify all the standard names when you use them
    • carefully choose your own names to avoid conflicts with standard names
    • place your own names inside a namespace (and don’t pull that into the global namespace).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've searched Google for this, but have only found similar examples--not exactly what I
I have already posted something similar here but I would like to ask the
I believe several of us have already worked on a project where not only
I have already tried PreRenderComplete and unload is too late
I have already googled for this I have a Table with following structure in
The basics have already been answered here . But is there a pre-built PHP
I know I have already answered a similar question ( Running Batch File in
I have a repository which I have already cloned from Subversion. I've been doing
In .NET I have already tried the configuration below successfully: <system.net> <connectionManagement> <add address=*
OK, I know there have already been questions about getting started with TDD ..

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.