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

  • Home
  • SEARCH
  • 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 7686455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:29:06+00:00 2026-05-31T19:29:06+00:00

Getting vector iterator not deferencable for code below, but I don’t see why. I

  • 0

Getting vector iterator not deferencable for code below, but I don’t see why. I am simply iterating through the 2d array and instantiating all values to 0. Where am I iterating to an invalid location?

vector<vector<bool>> isduplicate(100);

        for(int i=0;i<isduplicate.size();i++){
            for(int s=0;s<isduplicate.size();s++)
            isduplicate[i][s]=false;
        }
  • 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-31T19:29:07+00:00Added an answer on May 31, 2026 at 7:29 pm

    You are iterating over isduplicate twice. You should iterate over isduplicate[i] in the inner loop:

    vector<vector<bool>> isduplicate(100);
    for(int i=0;i<isduplicate.size();i++){
        for(int s=0;s<isduplicate[i].size();s++)
           isduplicate[i][s]=false;
    } 
    

    However, isduplicate[i] is empty for all i, therefore you won’t iterate over anything in the inner loop.

    If what you want is to have 100 vectors of 100 bools containing the false value, then:

    vector<vector<bool>> isduplicate(100, vector<bool>(100, false));
    

    Should do it.

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

Sidebar

Related Questions

I want to eliminate the junk that I'm getting on the vector<int> synsAux below.
Here is the code I am currently troubleshooting: void CTimer::notify() { std::vector<IObserver*>::iterator it; for(it=observers.begin();it!=observers.end();++it)
I'm trying to iterator through a map object using the following chunk of code:
Getting the above error in following code. How to rectify it. Thanks. Please look
i'm not a c++ coder so mayebe it's easy. i have a vector of
While getting ready for interviews, I decided to code the classic Find if there
I'm trying to encapsulate the C++ Standard Library's vector class using templates but I
Okay... I'm getting kind of desperate trying to get this code to work with
I am getting the run time error in following code. Please let me know
In the following code, I'm having some sort of issue getting my .yaml file

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.