plss help

1
2
3
4
5
6
7
8
9
10
11
12
typedef struct ProbWays
{
	double *probs ;
	int length ;
}ProbWays;
int main()
{
	ProbWays *ways = new ProbWays[];
	ways->probs = new double[4];
	ways->length = 4 ;
	delete ways ;
}


why this delete ways does not work , it causes heap error?
Line 8 doesn't even compile: you have to specify the size of the array.
Because ways is an array, you should change line 11 to delete [] ways;. Also you forgot to delete ways->probs.
Topic archived. No new replies allowed.