I need to cast interface pointer dynamically but my interfaces dont have any virtual method, basically i do not control the code of interfaces and i want to user same pointer to use methods from both interfaces, if i cast dynamically then since interfaces are not polymorphic type, it does not allow, what options do i have?
Code looks like this
Interface 2 : interface 1
{
foo();
}
Interface 3: Interface 2
{
koo();
}
some class
{
Interface 2 *ptr;
ptr->foo();
Now i want to user same pointer to access interface 3 methods
dynamicaly cast the interface pointer
Interface3 *ptr = dynamic_cast<Interface3 *>(ptr);
ptr->koo();
}
It tells me cant do since Interface3 is not polymorphic, now i do not have control over the interfaces, yet i want to use same pointer to both the interface, how can i achieve this?