OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gdb-6.8/] [pre-binutils-2.20.1-sync/] [gdb/] [testsuite/] [gdb.cp/] [mb-ctor.cc] - Diff between revs 157 and 223

Only display areas with differences | Details | Blame | View Log

Rev 157 Rev 223
 
 
#include <stdio.h>
#include <stdio.h>
 
 
class Base
class Base
{
{
public:
public:
  Base(int k);
  Base(int k);
  ~Base();
  ~Base();
  virtual void foo() {}
  virtual void foo() {}
private:
private:
  int k;
  int k;
};
};
 
 
Base::Base(int k)
Base::Base(int k)
{
{
  this->k = k;
  this->k = k;
}
}
 
 
Base::~Base()
Base::~Base()
{
{
    printf("~Base\n");
    printf("~Base\n");
}
}
 
 
class Derived : public virtual Base
class Derived : public virtual Base
{
{
public:
public:
  Derived(int i);
  Derived(int i);
  ~Derived();
  ~Derived();
private:
private:
  int i;
  int i;
};
};
 
 
Derived::Derived(int i) : Base(i)
Derived::Derived(int i) : Base(i)
{
{
  this->i = i;
  this->i = i;
}
}
 
 
Derived::~Derived()
Derived::~Derived()
{
{
    printf("~Derived\n");
    printf("~Derived\n");
}
}
 
 
class DeeplyDerived : public Derived
class DeeplyDerived : public Derived
{
{
public:
public:
  DeeplyDerived(int i) : Base(i), Derived(i) {}
  DeeplyDerived(int i) : Base(i), Derived(i) {}
};
};
 
 
int main()
int main()
{
{
  /* Invokes the Derived ctor that constructs both
  /* Invokes the Derived ctor that constructs both
     Derived and Base.  */
     Derived and Base.  */
  Derived d(7);
  Derived d(7);
  /* Invokes the Derived ctor that constructs only
  /* Invokes the Derived ctor that constructs only
     Derived. Base is constructed separately by
     Derived. Base is constructed separately by
     DeeplyDerived's ctor.  */
     DeeplyDerived's ctor.  */
  DeeplyDerived dd(15);
  DeeplyDerived dd(15);
}
}
 
 

powered by: WebSVN 2.1.0

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