blob: 24dbf6e7159ea5b5c3da36f835c620f4de921dbf (
plain)
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
27
28
29
|
// { dg-do run }
// prms-id: 789
extern "C" int printf (const char *, ...);
struct foo
{
static int count;
virtual void print (int i, int j) { printf ("foo[%d][%d] = %d\n", i, j, x); }
int x;
foo () { x = count++; }
};
int foo::count;
struct bar : virtual public foo
{
virtual void print (int i, int j) { printf ("bar[%d][%d] = %d\n", i, j, x); }
};
// bar array[3][3];
foo array[3][3];
int main ()
{
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++) {
// printf("&a[%d][%d] = %x\n", i, j, (void *)&array[i][j]);
array[i][j].print (i, j);
}
return 0;
}
|