Vector management problem while handling pointers

hi, i have this problem within this code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <vector>

typedef struct {
 int data1;
 int data2;
 char* data3;
} Struct1;

typedef struct {
 std::vector<Struct1> data;
 int more_data;
} Struct2;

int main() {
 Struct2 structure;
 Function(&structure);
 Function(&structure);
 Function(&structure);
 return 0;
}

void Function(Struct2* structure) {
 Struct1* child_structure = new Struct1;
 /*... modifying child_structure ...*/
 structure->data.push_back(child_structure);
}


Should I delete every pointer contained by the vector, or it does that by itself (i think it doesn't), cause i have to declare Struct1s as pointers?

thanks in advance.
Last edited on
you have to delete them yourself.
Topic archived. No new replies allowed.