initialization of class fields



  • Unprocessed exception at 0x00E34DF3 in kyrsovui.exe: 0xC0000005: violation of reading rights at 0x00000.

    Problem: not filled with a two-dimensional dynamism in a class designer. I've been staggering, the mass is being created, like, well filled up, but immediately after the completion cycle, if you look at the element that is? ?

    class Pole
    {
        public:
        int **main_mas;
        sf::Texture texture1;
        sf::Texture texture2;
        sf::Sprite sprite1;
        sf::Sprite sprite2;
    
    Pole();
    ~Pole();
    void draw_grid(sf::RenderWindow *);
    void draw_mas(sf::RenderWindow *);
    

    };

    Pole::Pole(){
    int **main_mas=new int *[20];
    for(int i=0;i<20;i++)
    main_mas[i]=new int[10];
    for(int i=0;i<20;i++)
    for(int w=0;w<10;w++)
    main_mas[i][w]=1;
    texture1.loadFromFile("images/square.png");
    sprite1.setTexture(texture1);
    texture2.loadFromFile("images/square_blue.png");
    sprite2.setTexture(texture2);
    }


  • QA Engineer

    Well, classic. You've declared a local variable, and you've got a sign in it, and you'll remove the designer from the first line.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2