#include <sigc++/sigc++.h>
#include <iostream>


class BaseBase
{
  int something;
};

class Derived;

class Base : virtual public sigc::trackable //BaseBase
{
public:
  Base()
  : m_as_derived(0)
  {}

  ~Base();

  Derived* m_as_derived;
};


class Base2
{
public:
  virtual ~Base2()
  {}
};


class Derived
  : virtual public Base,
    public Base2
{
public:
  Derived()
  {
    std::cout << "Derived: this=" << this << std::endl;
  }
};

Base::~Base()
{
  //Test a cast from Derived to Base, when instance's ~Derived() has run.
  std::cout << "~Base: this=" << this << std::endl;
  Base* as_base = m_as_derived;
  std::cout << "~Base: (Base*)this=" << as_base << std::endl;
}

int main(int argc, char **argv)
{
   Derived* instance = new Derived();
   instance->m_as_derived = instance; //In Base.
   delete instance;

   return 0;
}
