Hi,
Consider the code below:
These interfaces are defined in a header.
class IA
{
public:
virtual void A() = 0;
};
class IB
{
public:
virtual void B() = 0;
};
This concrete class is defined in a library which is later dynamically loaded.
class Implementation : public IA, public IB
{
public:
void A() {//Do something}
void B() {//Do something else}
};
extern "C" IA* GetObject() {return new Implementation();}
This is the main program
int main()
{
dlopen();
dlsym("");
IA* pA = GetObject(); //You get the idea
pA->A(); //Works fine
(IB*)pA->B(); //WRONG FUCNTION CALLED!(Destructor of Implementation class in my case)
}
What is wrong here, and how do I overcome it?
Thanks