I am working on a program in which everyting is perfect except Unhandled exception at 0x0041180c that I am getting at run-time and the location its specifying at is:

void candidateType::setVotes(int region, int votes)
{
votesByRegion[region-1]=votes;
}

I have checked it numerous times but still not getting it. Any help would be highly appreciated.

Yes, region is a vaid index and I have just sent the function where the error is pointing at.. can you please let me know if you need to look at the entire file because there are 6 file related to it.

Yes, region is a vaid index

region itself might be, but is it still valid in all cases when you subtract 1 from it?

The entire program was working perfectly with the same function... but now I just did multiple inheritance for one class and this is what I am getting. And yes, according to me, region is valid in all the cases. Wouldn't you mind looking at the code?

Wouldn't you mind looking at the code?

What code? The only thing you've posted looks fine, but has several unknowns which could be causing the problem. If you want better help, post a complete program that we can test.

The entire program was working perfectly with the same function... but now I just did multiple inheritance for one class and this is what I am getting. And yes, according to me, region is valid in all the cases. Wouldn't you mind looking at the code?

We need teh codez!!!

You need to post more code, that's for sure. If it is too big, just make a copy of it all, then strip away as much as you can without eliminating the error (unless you find the bug!), then post it.

Also, try this:

void candidateType::setVotes(int region, int votes)
{
  try {
    votesByRegion[region-1]=votes;
  } catch (...) {  //literally triple dots (not two, not four, three!)
    std::cout << "****** Exception was thrown with region = " << region << " and votes = " << votes << " ******" << std::endl;
    throw;
  };
};

I'm also pretty sure that region is 0 when the error occurs.

This article has been dead for over six months. Start a new discussion instead.