0
votes

I use Qt 4.6.3 to write application for FriendlyARM. I am trying to pass 2 pointers (pointing to classes axesParam1 and mainWin) to current class localTime but get these errors :

localtime.h:17: error: 'axesParam1' has not been declared
localtime.h:18: error: 'mainWin' has not been declared
localtime.h:26: error: ISO C++ forbids declaration of 'axesParam1' with no type
localtime.h:26: error: expected ';' before '*' token
localtime.h:27: error: ISO C++ forbids declaration of 'mainWin' with no type
localtime.h:27: error: expected ';' before '*' token
In file included from trackinputstatus.h:5,
from trackinput.h:5,
from mainwin.h:8,
from geoparam.h:5,
from axesparam3.h:5,
from axesparam2.h:5,
from axesparam1.h:5,
from main.cpp:14:
trackparamstatus.h:16: error: 'mainWin' has not been declared
trackparamstatus.h:24: error: ISO C++ forbids declaration of 'mainWin' with no type
trackparamstatus.h:24: error: expected ';' before '*' token
main.cpp: In function 'int main(int, char**)':
main.cpp:52: error: no matching function for call to 'localTime::setChildren(axesParam1*)'
localtime.h:17: note: candidates are: void localTime::setChildren(int*)
main.cpp:61: error: no matching function for call to 'localTime::setHome(mainWin*)'
localtime.h:18: note: candidates are: void localTime::setHome(int*)
main.cpp:62: error: no matching function for call to 'trackParamStatus::setHome(mainWin*)'
trackparamstatus.h:16: note: candidates are: void trackParamStatus::setHome(int*)

I did not declared setChildern to accept int* as an argument so why is it insisting on int*?

I have included the header file localtime.h

#ifndef LOCALTIME_H
#define LOCALTIME_H

#include  &ltQWidget>
#include "axesparam1.h"
#include "mainwin.h"

namespace Ui {
    class localTime;
}

class localTime : public QWidget {
    Q_OBJECT
public:
    localTime(QWidget *parent = 0);
    ~localTime();
    void setChildren(axesParam1 *);
    void setHome(mainWin *);


protected:
    void changeEvent(QEvent *e);

private:
    Ui::localTime *ui;
    axesParam1 *P1;
    mainWin *w;

};

#endif // LOCALTIME_H
1
Are you including localtime.h in axesparam1.h or in mainwin.h?thuga
@thuga I am using it in main.cpp. I thought that the header files declared (hence the classes declared) were restricted to a single cpp file when the cpp file isn't extended/implemented. Or am I missing something?VedVals
If axesparam1.h is including localtime.h, the declarations will be skipped due to the #ifndef line at the beginning of .h files. That is why I'm asking you to check if axesparam1.h is including localtime.h.thuga
@thuga so what to do when I need the class in multiple classes?VedVals
You use forward declaration. You can remove the axesparam1.h and mainwin.h includes from your localtime.h, and forward declare those classes. Then you include those headers in your localtime.cpp file. This should be a good read.thuga

1 Answers

0
votes

You look too far down. Before you look at setChildern you should look into axesparam1 and/or mainwin.

localtime.h:17: error: 'axesParam1' has not been declared localtime.h:18: error: 'mainWin' has not been declared

You have some syntex error earlier. setChildern is only some follow-up error.