gdb
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / mb-ctor.cc
CommitLineData
ed0616c6
VP
1
2#include <stdio.h>
3
4class Base
5{
6public:
7 Base(int k);
8 ~Base();
9 virtual void foo() {}
10private:
11 int k;
12};
13
14Base::Base(int k)
15{
16 this->k = k;
17}
18
19Base::~Base()
20{
21 printf("~Base\n");
22}
23
24class Derived : public virtual Base
25{
26public:
27 Derived(int i);
28 ~Derived();
29private:
30 int i;
31};
32
33Derived::Derived(int i) : Base(i)
34{
35 this->i = i;
36}
37
38Derived::~Derived()
39{
40 printf("~Derived\n");
41}
42
43class DeeplyDerived : public Derived
44{
45public:
46 DeeplyDerived(int i) : Base(i), Derived(i) {}
47};
48
49int 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.145386 seconds and 4 git commands to generate.