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