Scott
Scott

Reputation: 5263

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 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?

Upvotes: 1

Views: 4279

Answers (3)

ezdazuzena
ezdazuzena

Reputation: 6770

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.

Upvotes: 0

AnT stands with Russia
AnT stands with Russia

Reputation: 320361

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?

Upvotes: 4

Andrew Keith
Andrew Keith

Reputation: 7563

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

Upvotes: 4

Related Questions