1 Replies - 582 Views - Last Post: 04 July 2013 - 07:26 PM Rate Topic: -----

#1 Mylo  Icon User is offline

  • Knows all, except most.

Reputation: 265
  • View blog
  • Posts: 747
  • Joined: 11-October 11

Iterator::Find/Count() throwing access violation

Posted 04 July 2013 - 07:14 PM

Ok, forgot to initialize pointer again, why is it that I always forget this?

Grr c++, being complicated again.

I have the following pieces of code (trimmed unnecessary parts) that are throwing an access violation. Unhandled exception at 0x011160A6 in Space Invaders.exe: 0xC0000005: Access violation reading location 0x00000004. The 0x00000004 concerns me.

The constructors of all objects do nothing, apart from initializing a reference.

According to cplusplus.com, it.find() should just return x.end() if the element is not found. I tried replacing the code in registerState to mRegistered[50] = NULL; as a test, which also threw an access violation. It it my understanding that an access like this will just create that key/value pair with no problem.

mRegistered.count(id); throws the same exception.

Any ideas?


This post has been edited by Mylo: 04 July 2013 - 07:23 PM

Is This A Good Question/Topic? 0
  • +

Replies To: Iterator::Find/Count() throwing access violation

#2 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 6111
  • View blog
  • Posts: 21,033
  • Joined: 05-May 12

Re: Iterator::Find/Count() throwing access violation

Posted 04 July 2013 - 07:26 PM

Which line is the exception actually being thrown on? Is it the line where you are calling find() or on the line you are doing the assignment?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1