I want to make a function pointer that takes a parameter of the base class. I want to be able to create a function that pointer can point to but have it take a parameter of the derived class. I then want to be able to call the function parameter with the derived class and have it preform a function as if the parameter was the derived class. I want to be able to do something like this:
void(*pointer)(Base);
class Base
{};
class Something : public Base
{
public:
float f;
int i;
};
void doSomething(Something s)
{
//do something
}
int main()
{
Something s;
pointer = doSomething;
pointer(s);
return 0;
}
Is there anything I can do to make this work in c++?