Exception thrown at 0x78B3FF80 (ucrtbased.dll) in Project1.exe: 0xC0000005: Access violation reading location 0x00000000

-2
    if (is_ptr)
    {
        cout << "Release Year: " << is_ptr->get_releaseYear() << endl;
        cout << "Genre: " << is_ptr->get_genre_as_cstr() << endl;

    }

Hi smart ones. I am getting here this "Access violation reading location" error when I calling the function get_genre_as_cstr(). Below is the definition of the function:

enum class GENRE { ANY, POP, JAZZ, ROCK, INDIE, ELECTROPOP };
const char* get_genre_as_cstr() const
    {
        static const char* GENRE_cstr[]{ "Any", "Pop", "Jazz", "Rock", "Electropop" };
        return GENRE_cstr[(std::size_t)genre];
    }

Could you please help me solve this ?

c++
asked on Stack Overflow Mar 10, 2020 by Davrick

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0