SFML community forums

Help => Graphics => Topic started by: R23MJ on July 02, 2016, 01:10:26 am

Title: [SOLVED] Resource union throws access violation for Fonts.
Post by: R23MJ on July 02, 2016, 01:10:26 am
    So I am trying to write a Resource loader and manager (Yes I know of Thor, this is just a "learning" project.) and I have started experimenting with unions, not something I use very often. I created a class (as seen in code below) called resource which has a union that contains a texture/font. The texture loads correctly; however the font throws an access violation

Exception thrown at 0x00C5DBE0 in Project.exe: 0xC0000005: Access violation reading location 0x00000004.

The following is my complete and minimal example.
(click to show/hide)
Title: Re: Resource union throws access violation for Fonts.
Post by: R23MJ on July 02, 2016, 02:18:57 am
Evan, over at StackOverflow informed me that only the first element in a union is default constructed. This helped me solve the problem by assuring which ever item I plan to use in constructed properly before I use it.