say I have
class B{ //base class
}
class A : public B{ //derived class
}
I also have a function that returns a pointer to class B
B* returnB(){
B * object = new A; //pointer of base class allocate object of derived class
return object;
}
now when i try to make a pointer to function B*, I get an error
B* (*randomFunction)();
randomFunction = returnB;
Visual Studios wont compile.
1 IntelliSense: a value of type "B*(MediaFactory::*)()" cannot be assigned to an entity of type "B*(*)()" c:\Users\...\mediafactory.cpp 35
You seem to be trying to assign a pointer to a member function of class MediaFactory into a variable that can hold a non-member function. These entities aren't compatible. Either use boost bind or change your function pointer variable to be of B* (MediaFactory::*)() type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With