* gdb.cp/templates.cc (GetMax): New template.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / mb-ctor.cc
1
2 #include <stdio.h>
3
4 class Base
5 {
6 public:
7 Base(int k);
8 ~Base();
9 virtual void foo() {}
10 private:
11 int k;
12 };
13
14 Base::Base(int k)
15 {
16 this->k = k;
17 }
18
19 Base::~Base()
20 {
21 printf("~Base\n");
22 }
23
24 class Derived : public virtual Base
25 {
26 public:
27 Derived(int i);
28 ~Derived();
29 private:
30 int i;
31 };
32
33 Derived::Derived(int i) : Base(i)
34 {
35 this->i = i;
36 }
37
38 Derived::~Derived()
39 {
40 printf("~Derived\n");
41 }
42
43 class DeeplyDerived : public Derived
44 {
45 public:
46 DeeplyDerived(int i) : Base(i), Derived(i) {}
47 };
48
49 int main()
50 {
51 /* Invokes the Derived ctor that constructs both
52 Derived and Base. */
53 Derived d(7);
54 /* Invokes the Derived ctor that constructs only
55 Derived. Base is constructed separately by
56 DeeplyDerived's ctor. */
57 DeeplyDerived dd(15);
58 }
This page took 0.03268 seconds and 4 git commands to generate.