function definition does not declare parameters
-
05-07-2019 - |
Question
What's wrong with TextLayoutTransition? Can function pointers not be declared virtual?
LCDWrapper.h:23: error: function definition does not declare parameters
Here's the class.
class LCDInterface {
public:
// Slots
virtual void TextSetSpecialChars() = 0;
virtual void LayoutChangeBefore() = 0;
virtual void LayoutChangeAfter() = 0;
virtual void TextSpecialCharChanged(unsigned int i) = 0;
virtual void ChangeLayout() = 0;
virtual void (*TextLayoutTransition)(Generic<LCDText> *v){}; // line 23
virtual void TransitionFinished() = 0;
};
Edit: Slightly related, and related to Qt, can function pointers be declared as slots/signals?
Solution
No, you cant.. it doesnt make sense to put virtual on a function pointer. You cant override a variable.
OTHER TIPS
Function pointers are data. Data members can't be virtual. And they can't have a "body" defined through {}
as in your example. What were you trying to do with this?
Also not related to the example in the question, though you get the same error message when having the following code:
class myClass
{
public:
get_a { return a; }; // <-- missing () !!!
private:
int a;
};
The (obvious) problem is the lack of ()
after the method get_a.
Hope that helps people following the link when reading the title of the question.