0
我在这里做错了什么? 我需要做第二个构造函数接受一个值的结构。将结构传递给构造函数
note.h
class Traymenu;
class Note : public QWidget
{
Q_OBJECT
public:
explicit Note(Traymenu *trayMenuIn, QWidget *parent = 0); //Working
explicit Note(Traymenu *trayMenuIn, struct prop bla, QWidget *parent = 0); //ERROR forward declaration of "struct prop"
note.h(可选择性)
class Traymenu;
struct prop; //ERROR: forward declaration of "struct prop"
class Note : public QWidget
{
Q_OBJECT
public:
explicit Note(Traymenu *trayMenuIn, QWidget *parent = 0);
explicit Note(Traymenu *trayMenuIn, struct prop bla, QWidget *parent = 0); //ERROR forward declaration of "struct prop"
note.cpp
#include "note.h"
Note::Note(Traymenu *trayMenuIn, struct prop bla, QWidget *parent) : //ERROR: bla has incomplete type
'struct'关键字可以用来转发声明 – Paranaix
@Paranaix是的,这是必要的,但不是在接受参数时。 – pmr
我在另一个调用'Note'构造函数的类中声明了我的'struct prop'作为公共成员变量。嗯。它不能被引用,因为在调用构造函数 – user2366975