Example
int
main(
int
argc,
char
* argv[])
{
int
*a =
static_cast
<
int
*>(malloc(
sizeof
(
int
)));
delete
a;
int
*b =
new
int
;
free(b);
return
0;
}
Solution
Use free() to deallocate memory allocated with malloc() and "delete" to deallocate memory allocated with "new".
int
main(
int
argc,
char
* argv[])
{
int
*a =
static_cast
<
int
*>(malloc(
sizeof
(
int
)));
free(a);
int
*b =
new
int
;
delete
b;
return
0;
}