1 | #include <stdio.h> |
2 | |
3 | class Point { |
4 | public: |
5 | int x; |
6 | int y; |
7 | Point(int a, int b): |
8 | x(a), |
9 | y(b) |
10 | {} |
11 | }; |
12 | |
13 | class Data { |
14 | public: |
15 | int id; |
16 | Point point; |
17 | Data(int i): |
18 | id(i), |
19 | point(0, 0) |
20 | {} |
21 | }; |
22 | |
23 | int main(int argc, char const *argv[]) { |
24 | Data *data[1000]; |
25 | Data **ptr = data; |
26 | for (int i = 0; i < 1000; ++i) { |
27 | ptr[i] = new Data(i); |
28 | ptr[i]->point.x = i; |
29 | ptr[i]->point.y = i+1; |
30 | } |
31 | |
32 | printf(format: "Finished populating data.\n" ); |
33 | for (int j = 0; j < 1000; ++j) { |
34 | bool dump = argc > 1; // Set breakpoint here. |
35 | // Evaluate a couple of expressions (2*1000 = 2000 exprs): |
36 | // expr ptr[j]->point.x |
37 | // expr ptr[j]->point.y |
38 | if (dump) { |
39 | printf(format: "data[%d] = %d (%d, %d)\n" , j, ptr[j]->id, ptr[j]->point.x, ptr[j]->point.y); |
40 | } |
41 | } |
42 | return 0; |
43 | } |
44 | |