Hi, I would like to know if its possible to have an array of void* and everytime I allocate a memory I would add its pointer to the array of void*, and then in the end of my application I would just go through the list of the void* and deleting every one. Is that possible?
Example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 | //application init//
struct myStruct
{
int anInt = 3;
float aFloat = 40.0f;
}
void** pointers = new void*[3];
for(int i = 0; i < 3; i++)
{
myStruct* ms = new myStruct();
pointers.push_back(ms);
}
//application loop//
//application end//
for(int i = 0; i < 3; i++)
{
delete pointers[i];
}
|