OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.cp/] [mb-ctor.cc] - Blame information for rev 294

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 jeremybenn
 
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
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.