开发者

function definition does not declare parameters

开发者 https://www.devze.com 2022-12-08 22:57 出处:网络
What\'s wrong with TextLayoutTransition? Can function pointers not be declared virtual? LCDWrapper.h:23: error: function definition does not declare parameters

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 LC开发者_开发问答DInterface {
    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?


No, you cant.. it doesnt make sense to put virtual on a function pointer. You cant override a variable.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消