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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:57:24+00:00 2026-05-27T09:57:24+00:00

I have a problem using the STL containers in c++ function 1; void addStudent(const

  • 0

I have a problem using the STL containers in c++

function 1;

void addStudent(const Student &s){                       
    set<GradeColumn>::iterator itr;

    for(itr = gradeColumns.begin(); itr != gradeColumns.end(); itr++){
        itr->addStudent(s, DID_NOT_COMPLETE);
    }
}

function 2:

void addStudent(const Student &s,  int grade) const {
    column.insert(pair<Student, int>(s, grade));
}

Okay, so in function 1 I use addStudent, but the compiler gives me an error unless I declare addStudent as a const function (the error is “The object has type qualifiers that are not compatible with the member function”).

But if I do declare addStudent as a const function, then column.insert(…) gives me thee next error: “No instance of overloaded function matches the argument list and object 9the object has type qualifiers that prevent a match)”.

Is there any way to fix that? Am I missing something?

Thanks!

  • 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-27T09:57:24+00:00Added an answer on May 27, 2026 at 9:57 am

    The problem here is that the class you are trying to modify is also the key in the set. And this is required to be immutable. i.e. it is not correct behaviour to change the key once the item is in the set.

    You need to consider a different structure, I would advice that you extract the key element out into a separate key structure and use a map to map the key to the mutable data content of your structure.

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

Sidebar

Related Questions

I enjoy developing algorithms using the STL, however, I have this recurring problem where
I have a problem using the Java search function in Eclipse on a particular
I'd have to say I'm no expert on using the STL. Here's my problem,
I'm having a problem using inheritance and the STL list library... Say, I have
I have problem when using modalPresentationStyle. I call the following function in my tabbarcontroller's
I have problem while using jquery maskedinput with asp.net textbox. I have a check
I have a problem using Linq to NHibernate to load an object and eagerly
I have a problem using the SSIS. I try to import data from database
I have a problem using JSON and arrays. Here is my code: while($row =
i have a problem using the Catch Clipboard Events code found on this link

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.