Bonjours à tous, je suis sur la construction d'un petit moteur 2d et je n'arrive pas à savoir si la mémoire allouée est bien vidée, pouvez vous me l'affirmer ou me corriger si possible, merci ! (tableau 2 dimensions de type char)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 
///SOURCE
#include "Quad.h"
 
//INITIALISATION
Quad::Quad(const int width, const int height)
{
//Dimensions du Quad
    this -> width = width;
    this -> height = height;
 
//Création du tableau de char : quad[largeur][hauteur]
    quad = new unsigned char *[width];
    for(int x = 0; x < width; x++)
        quad[x] = new unsigned char [height];
}
 
//DESTRUCTION
Quad::~Quad()
{
//Vidage de la mémoire
 
    for(int y = 0; y < height; y++)
        delete[] quad[y];
    delete[] quad;
 
}
 
 
 
///Header
#ifndef QUAD
#define QUAD
 
class Quad
{
public:
    //INITIALISATION
    Quad(const int, const int);
    ~Quad();
 
    //QUAD PROPRETY
    inline int GetWidth() { return width; }
    inline int GetHeight() { return height; } }[(int)y] = stat; }
 
private:
    unsigned char **quad;
    int width, height;
};
 
#endif // QUAD