I begin to use clang to replace gcc. But when I delete[] pointers, it gives warning. But when I change, the warning disappears. Why and how to deal with that?
int *a = new int[1];
int *b = new int[1];
delete[] a, b;
a.cpp:7:17: warning: expression result unused [-Wunused-value]
delete[] a, b;
int *a = new int[1];
int *b = new int[1];
delete[] a;
delete[] b;
no warning.
deletein a destructor - onedeleteper destructor. If you have two things that need to be deleted, you use two members managing one each. And often you don't need to write thatdeleteyourself. E.g.std::vector<int>manages thedelete[]for you.