I'm developing an application using Qt Widgets.
In my header files, I like to forward declare classes instead of including them. At the beginning of a header file I put forward declarations as follows:
class QFile;
class QDate;
class QTime;
And, there is a function declaration in the class as the following:
static bool addGoldTransaction(QFile *transactionsFile, Gold goldType, OperationType transactionType, float price, float amount, QDate date, QTime time);
When I try to compile, it gives an error like the following:
forward declaration of 'class QDate'
in definition of macro 'QT_FORWARD_DECLARE_STATIC_TYPES_ITER'
in expansion of macro 'QT_FOR_EACH_STATIC_CORE_CLASS'
In file included from moc_transaction.cpp:9:0:
error: initializing argument 6 of 'static bool addGoldTransaction(QFile*, Gold, OperationType, float, float, QDate, QTime)'
There is no error for forward declarations of other Qt-related classes.
Including the QDate
header file solves the issue but I wonder:
QDate
class while it doesn't complain about other classes? Is there anything special with QDate
class related to this issue?QDate
class?Pass 6 and 7 arguments of types QDate
and QTime
by references QDate&
and QTime&
or better by const references const QDate&
and const QTime&
.