• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <stdlib.h>
2 
main()3 int main()
4 {
5   int* fpointer = (int*)malloc(10);
6   delete fpointer;          // should give warning
7   fpointer = (int*)malloc(10);
8   delete [] fpointer;       // should give warning
9   fpointer = (int*)malloc(10);
10   free (fpointer);          // should work!
11 
12   int* nvec = new int[10];
13   delete nvec;              // should give a warning
14   nvec = new int[10];
15   free (nvec);              // should give a warning
16   nvec = new int[10];
17   delete [] nvec;           // should work!
18 
19   int* n = new int;
20   delete [] n;              // should give a warning
21   n = new int;
22   free(n);                  // should give a warning
23   n = new int;
24   delete n;                 // should work!
25 
26   return 0;
27 }
28