blob: 2a2447d02c89132785d50bc410f05deb7b502e2c (
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// { dg-do run }
struct base
{
int total;
virtual void add (int i) { total += i; }
virtual void sub (int i) { total -= i; }
virtual void init (void) { total = 73; }
};
struct derived : public base
{
int total;
virtual void add (int i) { total += 10 * i; }
virtual void sub (int i) { total -= 2 * i; }
virtual void init (void) { total = 0; }
};
bool
get_cond_value (int x)
{
if ((x % 3) > 0)
return true;
else
return false;
return false;
}
int
main (int argc, char **argv)
{
base *a;
bool cond_value = get_cond_value (10);
int x;
if (cond_value)
a = new base ();
else
a = new derived ();
cond_value = get_cond_value (47);
x = 0;
if (!cond_value)
x = 17;
a->init ();
for ( ; x < 10; ++x)
{
a->add(50);
a->sub(25);
}
}
|