Reputation: 3359
#define NB -3
#define NM -2
#define NS -1
#define ZO 0
#define PS 1
#define PM 2
#define PB 3
int (*rule)[7] =new int[7][7]{{NB,NB,NM,NM,NS,ZO,ZO},
{NB,NB,NM,NS,NS,ZO,PS},
{NM,NM,NM,NS,ZO,PS,PS},
{NM,NM,NS,ZO,PS,PM,PM},
{NS,NS,ZO,PS,PS,PM,PM},
{NS,ZO,PS,PM,PM,PM,PB},
{ZO,ZO,PM,PM,PM,PB,PB}};
should I use the following method?
for(int i=0;i<7;++i)
{
delete[] rule++;
}
Or if I use delete[] rule
, it seems weird becuse the underlying object is an array of arrrays, but not array of pointers, which is the type of rule
.
Upvotes: 0
Views: 61
Reputation: 234695
rule
is an array of pointers to type int[7]
.
The former was declared with a new[]
.
Therefore you need to use delete[] rule;
to release the memory.
Upvotes: 1