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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.cp/] [mb-ctor.cc] - Diff between revs 827 and 840

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 827 Rev 840
 
 
#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.