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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:10:59+00:00 2026-06-11T03:10:59+00:00

I am attempting to print out all of the elements in each vector from

  • 0

I am attempting to print out all of the elements in each vector from a multiset of vectors. The build is failing but the error is occurring somewhere in a header file, I’m afraid I don’t really understand the error codes at all. Any help would be greatly appreciated! Here is the error:

error: invalid conversion from 'const std::basic_string<char, std::char_traits<char>, std::allocator<char> >* const' to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >*'

And here is the code causing the problems.

multiset<vector < string > > setOfRules;
vector<string> testing,testing2;

testing.push_back("bar");
testing.push_back("foo");
testing2.push_back("foo2");
testing2.push_back("bar2");
setOfRules.insert(testing);
setOfRules.insert(testing2);

for (multiset< vector <string > >::iterator myIterator = setOfRules.begin();
     myIterator!=setOfRules.end(); 
     ++myIterator) 
{

    for (vector< string >::iterator myOtherIterator = ( *myIterator ).begin(); 
         myOtherIterator != ( *myIterator ).end(); 
         ++myOtherIterator) 
    {
        cout << *myOtherIterator << " " ;
    }
    cout << endl;
}
  • 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-11T03:11:01+00:00Added an answer on June 11, 2026 at 3:11 am

    C++11 Standard claims that for associative containers where the value type is the same as the key type, both iterator and const_iterator are constant iterators.

    So actually multiset<vector<string>>::iterator is const_iterator. The same trick with std::set iterators – they are all consts.

    This means that vector<string>::iterator myOtherIterator = *myIterator.begin() statement will fail because you try obtain non-const iterator from const object (given by *myIterator which is const).

    To fix you need to use vector<string>::const_iterator:

    for(multiset<vector<string>>::const_iterator myIterator = setOfRules.begin(); 
        myIterator != setOfRules.end(); ++myIterator)
    {
       for(vector<string>::const_iterator myOtherIterator = *myIterator.begin();     
          myOtherIterator != *myIterator.end(); ++myOtherIterator)
       {
          cout << *myOtherIterator << " ";
       }
       cout << endl;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to print a bitmap from an Espon receipt printer. The full error
I am attempting to print out lables (bar codes) from a table using JS
My google-fu's failing me again. The information is (probably) out there, but I can't
I was attempting to use the following if/else statements to build a query, but
I am attempting to read each integer from an infile and passing that on
I am attempting to print a JPEG file that I reference using a Uri
When I print the result of the regex I am attempting to use to
Attempting to build a C# NPAPI plugin I have found a tutorial which describes
Attempting to use the data series from this example no longer passes the JSONLint
I am attempting to visualize / understand my Rails application hierarchy on each page

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.