I cannot seem to figure out how to do instance based callbacks for some
reason. I found one site on functors but I did not find it that helpful
actually I just don't understand it.
I have no problem doing non-instance based callbacks.
I want to be able to pass a function into a constructor and from inside the
class make a call make a call to the instance based function of another
class. Do i have to use templates?
so,
class Car {
Car( // instance based function ) {} // pass the instance based
function in the constructor
startCar() {
// make a call to Start Car in the Engine Class that is make a
call to another classes function which is not static.
}
};
class Engine {
Engine(){}
startCar() { std::cout << "started car" << std::endl; } // this function
is called from another class, this is not static.
};
int main()
{
Car car1( // pass instance based function ) // create a constructor and
pass the instance based function in
return 0;
}
Sorry if this is confusing, any guidance is greatly appreciated.