There is a class in which you need to define and initialize the string. I understand that in classes you can only define intovy variables to the same static and constants.

class Background:public environment { public: static const char* str_to_bckgrnd="Images/environment/33.png"; }AS; 

the error is as follows: only static const integral data members can be initialized within a class

Why such a construction is not allowed? And how can we deal with the line differently?

    1 answer 1

    And why don't you do what the compiler asks: render the string initialization from within the class declaration?

     class Background : public environment { public: static const char* str_to_bckgrnd; } AS; const char* Background::str_to_bckgrnd="Images/environment/33.png"; 

    Check .

    • wow) awkward happened. thanks - Dexter384
    • one
      @ Dexter384: Don't worry too much: C ++ syntax is one of the most confusing and illogical. - VladD