I have the following classes:
class Base {
public:
  virtual ~Base(){}
  Base() {}
  virtual void foo() = 0;
};
class Derived : public Base {
public:
  virtual ~Derived(){}
  Derived() : Base() {}
  void foo() { printf("derived : foo\n"); }
};
class IInterface {
public:
  virtual ~IInterface() {}
  virtual void bar() = 0;
};
class C : public Derived, public IInterface {
public:
  virtual ~C(){}
  C() : Derived(){}
  void bar() { printf("C : bar\n"); }
};
now I have a bunch of Derived* objects and I want to apply different interfaces on them :
  Derived* d = new Derived();
  C* c = dynamic_cast<C*>(d);
  c->bar();
  c->foo();
dynamic_cast returns nullptr and with c-style cast i get seg fault. is there anyway to achieve this?
note that my objects are already created with Derived ctor.
i just want to treat them differently using Interfaces
 
     
     
    