为类似函数的宏调用提供的参数太少(在包含的文件中)

问题描述 投票:0回答:1
  • 我有一个Qt项目
  • 在文件“lab2.h”中包含指令(旁边签名)的行旁边出现此错误
#ifndef LAB2_H
#define LAB2_H

#include <QWidget>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QPlainTextEdit>
#include <QFrame>
#include "element.h" //too few arguments provided to function-like macro invocation element.h:24:25note: error occurred here:Qt\6.7.0\mingw_64\include...


class lab2 : public QWidget
{
    Q_OBJECT

protected:
    QFrame *f;
    QLabel *label;
    QLineEdit *edit;
    QPlainTextEdit *box;
    QPushButton *add;
    QPushButton *del;
    QPushButton *first;
    QPushButton *last;
    QPushButton *all;
    QPushButton *exit;
    QPushButton *sum;

    lists my_list;
    element *q;

public:
    lab2(QWidget *parent = nullptr);
    ~lab2();
public slots:
    void beg();
    void fi();
    void de();
    void la();
    void lla();
    void S();
};

class numi: public element{
public:
    int i;
    numi(int n):element(){
        i=n;
    }
    std::string show()override{
        std::string ret="";
        ret+=std::to_string(i);
        return ret;
    }
    ~numi() override{}
};

class numf: public element{
public:
    double f;
    numf(double m): element(){f=m;}
    std::string show()override{
        std::string ret="";
        ret+=std::to_string(f);
        return ret;
    }
    ~numf()override{}
};
#endif // LAB2_H
  • 来自文件“element.h”以及类的描述
#ifndef ELEMENT_H
#define ELEMENT_H

#include <string>


class element
{
public:
    element *p;
    element(){p=nullptr;};
    virtual ~element(){}
    virtual std::string show()=0;
};

class lists{
private:
    element *f,*l,*c;
public:
    lists();
    void add(element *q);
    ~lists();
    void del();
    std::string foreach();
    std::string sym();
    element *fist();
    element *last();

};

class E{
public:
    int e;
    E(int ae);
    std::string error();
};

#endif // ELEMENT_H

在寻找类似的问题后,我意识到我在某个地方失去了论点。我不太明白在哪里寻找错误

c++ qt compiler-errors qt-creator function-call
1个回答
0
投票

好的,我的函数与 foreach() 宏同名。为了简单起见,我没有初始化 #define,而是将其重命名为 foreachLists()

© www.soinside.com 2019 - 2024. All rights reserved.