// This code is public-domain.
// Copyright (c) 2006 by Patrick Stählin <me@packi.ch>

#include <iostream>

using namespace std;

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

class B : public A {
};

class C : public A {
};

class F {
};

class D : public C,F {
};


void test( A* _c ) {
  if( dynamic_cast<B*>(_c) ) {
    cout << "is B" << endl;
  }
  if( dynamic_cast<C*>(_c) ) {
    cout << "is C" << endl;
  }
  if( dynamic_cast<F*>(_c) ) {
    cout << "is F" << endl;
  }
}

int main() {
  cout << "creating B" << endl;
  test( new B() );
  cout << "creating C" << endl;
  test( new C() );
  cout << "creating D" << endl;
  test( new D() );
  return 0;
}

