I'm programming my own game editor and it consists of lots of DLLs. Some DLLs uses other DLLs to derive some classes. The problem is whenever I call a virtual function (pure or not, result is same) with base class' pointer, application crashes. To visualize:
//DLL1.h in DLL1
class Base{
static Base* SELF; //I use this to access functions
void DoSometing(); //Defined in DLL1.cpp
virtual void VirtualSomething();
};
//DLL2.h in DLL2
class Derived : public Base{
virtual void VirtualSomething(); //Defined in DLL2.cpp
};
//main.cpp in APP.exe
void main(){
Base::SELF = new Derived;
Base::SELF->DoSomething(); //Works fine
Base::SELF->VirtualSomething(); //Crashes
}
Note: I have to use the Base::SELF pointer because I want to change it with another DLL later. It seems pretty awkward to create a Derived pointer and set it as Base::SELF here but it's more complicated than that, I'm creating this pointers in another DLL and pass them to application. I just wanted to give you the idea.
There was nothing wrong with it, again a VS Debugger issue. Deleting some functions worked!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.