hi, I saw an example of using the function: delete in cpp and I didn't completely understand it. the code is:
class Name {
const char* s;
//...
};
class Table {
Name* p;
size_t sz;
public:
Table(size_t s = 15){p = new Name[sz = s]; }
~Table { delete[] p; }
};
what is the exact action of the command: delete[] p;?
I think the aim was to delete all the pointers in the container Table.
the brackets in "delete[]" give me a clue that it deletes an array of pointers to Name but the size of the array is not specified, so how does the destructor "know" how many pointers to delete.