I have two classes, A and Bar, both share a header file that has essentially Foo* foo in it. Class A instantiates an object Bar* bar. This works fine. However, if I make the instantiation of the object
Bar* bar = new Bar();
I get an access violation when bar attempts to do something with foo. Why does this make a difference?
If I don't use 'new' it works fine. This is the error:
Unhandled exception at 0x003c17ea in Direct3DTutorial7.exe: 0xC0000005: Access violation reading
location 0x00000000.
Thanks.
0xC0000005: Access violation reading location 0x00000000.
This means you're dereferencing a null pointer, likely in the constructor of Bar
, or in some other code called by this constructor. Use a debugger to determine exactly where.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With