How to handle pointers in plugins,or abstract classes
-
interface.h
@
...
interface();//constructor
virtual void setNum(int*)=0;
...
@plugin.cpp
@
...
public:
void setNum(int *i){
num=i;
}
private:
int *num;
@i will load the plugin using QPluginLoader,then create an instance from the interface
@QObject * QPluginLoader::instance()@so how to handle the memory and prevent memory leak?how do i delete the instances i create?
Edit:
if i delete the pointer in the destructor of "plugin class"will the destructor "plugin class" be called when calling @bool QPluginLoader::unload()@
-
It's described in the documentation "here":http://qt-project.org/doc/qt-5/QPluginLoader.html#details and "here":http://qt-project.org/doc/qt-5/qpluginloader.html#instance