Is there a way to have a pointer to a function inside a referenced class?
I've tried replacing the reference to a class with another pointer, did not work.
I've also tried using ->
instead of .
, no luck.
class First {
void FunToPointTo();
};
class Second {
First &reference;
void (*pointer)();
Second(First &first);
};
Second::Second(First &first) : reference(first) {
pointer = reference.FunToPointTo;
}
Error: cannot convert 'First::FunToPointTo' from type 'void (First::)()' to type 'void (*)()'
Now I am trying to somehow make my pointer into void (First::)()
, but I don't know the exact syntax.
Help is greatly appreciated, also please excuse my lack of knowledge as I am just starting c++.