PDA

View Full Version : expected constructor, destructor, or type conversion before '(' token



cuteatul
7th July 2011, 11:27
Hi...

I am using qnetworkaccessmanager.h header file at the top of main.cpp class in console application...

and i am getting this error.....

"expected constructor, destructor, or type conversion before '(' token"

what could be the couse for this issue...
plz help me..
thanks

ChrisW67
7th July 2011, 11:33
A syntax error in your code, usually a missing semi-colon or #include, but without your code we cannot tell.

cuteatul
7th July 2011, 11:48
Thanks for ur reply.. but when I click on the error .. it takes me to qnetworkaccessmanager.h file itself and
the code is here


DECLARE_INTERFACE_(IAMMediaContent, IDispatch)
{
STDMETHOD(get_AuthorName)(THIS_ BSTR*) PURE;
STDMETHOD(get_Title)(THIS_ BSTR*) PURE;
STDMETHOD(get_Rating)(THIS_ BSTR*) PURE;
STDMETHOD(get_Description)(THIS_ BSTR*) PURE;
STDMETHOD(get_Copyright)(THIS_ BSTR*) PURE;
STDMETHOD(get_BaseURL)(THIS_ BSTR*) PURE;
STDMETHOD(get_LogoURL)(THIS_ BSTR*) PURE;
STDMETHOD(get_LogoIconURL)(THIS_ BSTR*) PURE;
STDMETHOD(get_WatermarkURL)(THIS_ BSTR*) PURE;
STDMETHOD(get_MoreInfoURL)(THIS_ BSTR*) PURE;
STDMETHOD(get_MoreInfoBannerImage)(THIS_ BSTR*) PURE;
STDMETHOD(get_MoreInfoBannerURL)(THIS_ BSTR*) PURE;
STDMETHOD(get_MoreInfoText)(THIS_ BSTR*) PURE;
};

ChrisW67
7th July 2011, 11:49
What immediately precedes your #include <QNetworkAccessManager> line?

cuteatul
7th July 2011, 11:52
Thanks for ur reply.. but when I click on the error .. it takes me to qnetworkaccessmanager.h file itself and
the code is here..



DECLARE_INTERFACE_(IAMMediaContent, IDispatch)
{
STDMETHOD(get_AuthorName)(THIS_ BSTR*) PURE;
STDMETHOD(get_Title)(THIS_ BSTR*) PURE;
STDMETHOD(get_Rating)(THIS_ BSTR*) PURE;
STDMETHOD(get_Description)(THIS_ BSTR*) PURE;
STDMETHOD(get_Copyright)(THIS_ BSTR*) PURE;
STDMETHOD(get_BaseURL)(THIS_ BSTR*) PURE;
STDMETHOD(get_LogoURL)(THIS_ BSTR*) PURE;
STDMETHOD(get_LogoIconURL)(THIS_ BSTR*) PURE;
STDMETHOD(get_WatermarkURL)(THIS_ BSTR*) PURE;
STDMETHOD(get_MoreInfoURL)(THIS_ BSTR*) PURE;
STDMETHOD(get_MoreInfoBannerImage)(THIS_ BSTR*) PURE;
STDMETHOD(get_MoreInfoBannerURL)(THIS_ BSTR*) PURE;
STDMETHOD(get_MoreInfoText)(THIS_ BSTR*) PURE;
};


my header section is:



#include <QtCore/QCoreApplication>
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <qnetwork.h>
#include <qnetworkaccessmanager.h>

stampede
7th July 2011, 12:36
Can you post the whole main.cpp and error message (including line number) ?

mcosta
7th July 2011, 12:40
The source you posted is <qnetwork.h> and it isn't a Qt header file.

cuteatul
7th July 2011, 12:52
My main.cpp is


#include <QtCore/QCoreApplication>
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <qnetwork.h>
#include <qnetworkaccessmanager.h>

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QNetworkAccessManager *manager = new QNetworkAccessManager(this);


return a.exec();
}



and error messages are

c:\qtsdk\mingw\bin\..\lib\gcc\mingw32\4.4.0\..\..\ ..\..\include\qnetwork.h:16: error: expected constructor, destructor, or type conversion before '(' token

mcosta
7th July 2011, 12:57
My main.cpp is


#include <QtCore/QCoreApplication>
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <qnetwork.h>
#include <qnetworkaccessmanager.h>

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QNetworkAccessManager *manager = new QNetworkAccessManager(this);


return a.exec();
}



and error messages are

c:\qtsdk\mingw\bin\..\lib\gcc\mingw32\4.4.0\..\..\ ..\..\include\qnetwork.h:16: error: expected constructor, destructor, or type conversion before '(' token

the problem is in the <qnetwork.h> file, try compile your main without including it.

cuteatul
7th July 2011, 12:59
Ya then it compiles successfully....
but qnetwork.h is not hard coded file ... it is a predefined file.....
so how should I look for errors in this file..................?????

ChrisW67
7th July 2011, 22:55
Firstly, if your program compiles without it then you don't need it, and don't need to correct errors in it.

Secondly, as advised earlier, qnetwork.h is not part of Qt. It has dependencies that you are missing before the include, specifically:

To define the interface identifier, include the header file Initguid.h before Qnetwork.h, but after Dshow.h and other header files:


#include <dshow.h>
#include <initguid.h>
#include <qnetwork.h>

Note Make sure that Initguid.h is included only once in your project. Otherwise, you will receive linker errors for duplicate GUID values.
as in the Microsoft docs (http://msdn.microsoft.com/en-us/library/dd319638%28v=vs.85%29.aspx) clearly states. If there are errors internal to that file (I strongly doubt it) then you need to address that with the author.

cuteatul
8th July 2011, 05:55
Thanks.. it solves my problem.... But after doing this I am getting one error ... here is

c:\qtsdk\mingw\bin\..\lib\gcc\mingw32\4.4.0\..\..\ ..\..\include\qnetwork.h:46: error: expected unqualified-id before '}' token

and I want to be clear about if qnetwork.h is a part of qt framework or not.......

nish
8th July 2011, 06:23
<qnetwork.h> is not.. Qt has <QtNetwork>