PDA

View Full Version : error: expected class-name before '{' token



abrou
22nd February 2008, 17:33
Hello, I've been pulling my hair out trying to figure out how to fix this. I don't have a lot of experience with OOP, so I'm at a bit of a dead end. I am using qt 4.3.3 with visual studio 2005 express.

I am getting an error:



------ Build started: Project: RoboSearch, Configuration: Debug Win32 ------
Performing Makefile project actions
mingw32-make -f Makefile.Debug
saveDOM.cpp:11:20: warning: extra tokens at end of #include directive
saveDOM.cpp:12:21: warning: extra tokens at end of #include directive
In file included from saveDOM.cpp:12:
saveDOM.h:20: error: expected class-name before '{' token
In file included from saveDOM.cpp:12:
saveDOM.h:31:7: warning: no newline at end of file
mingw32-make[1]: *** [debug/saveDOM.o] Error 1
mingw32-make[1]: Leaving directory `c:/Documents and Settings/abrounstein/My Documents/Visual Studio 2005/Projects/RoboSearch/RoboSearch'
mingw32-make: *** [debug] Error 2
Build log was saved at "file://c:\Documents and Settings\abrounstein\My Documents\Visual Studio 2005\Projects\RoboSearch\RoboSearch\Debug\BuildLog .htm"
RoboSearch - 1 error(s), 3 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
The header file is this:




#ifndef SAVEDOM_H
#define SAVEDOM_H

#include <Qt>
#include <QtGui>
#include <QLabel>
#include "ui_saveDOM.h"
#include "qdom.h"
#include <QDomDocument>
#include <QDir>

class saveDOM : public QMainWindow, private Ui::saveDOM
{ //line 22
...
};
#endif



The .cpp file currently empty (although it wasn't at one point, it didn't change the errors)

What is strange is that I literally copied this from another header file in the same project which compiles and runs fine. When I take out the inheritence, I still seem to get the same problem. And yes, I am using the same compilier.

I originally posted this in a c++ forum, but I talked to someone I work with who is an experience programmer, but he said my code seemed sound to him. Is it maybe a qt problem?

Does anyone have any suggestions? Thanks!

Let me know if more information is needed.

jpn
22nd February 2008, 17:56
Could you attach relevant files?

ui_saveDOM.h
saveDOM.h
saveDOM.cpp

abrou
22nd February 2008, 18:02
Yes, here they are. They are not the only files in the project, and they are just skeletons right now, while I try to get this to work.

jpn
22nd February 2008, 18:07
saveDOM.cpp:11:20: warning: extra tokens at end of #include directive
saveDOM.cpp:12:21: warning: extra tokens at end of #include directive



#include "saveDOM.h"; // <-- remove ";"
#include <QtDebug>; // <-- remove ";"




In file included from saveDOM.cpp:12:
saveDOM.h:20: error: expected class-name before '{' token



class saveDOM : public QMainWindow, private Ui:savedom // <-- should be "Ui::MainWindow" (*)

(*) because that's how the form was named in Qt Designer

abrou
22nd February 2008, 19:08
That's it, thanks!