PDA

View Full Version : error with constructor or OnInit



chochatown
30th May 2009, 03:02
i have an error with Oninit methode after the make,this error ii dont know why it comes i paste you my error and my code and thx for your help :

make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/local/include -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -Isrc -Iinc -I. -I. -o App.o src/App.cpp
src/App.cpp:41: erreur: expected constructor, destructor, or type conversion before «bool»
make: *** [App.o] Erreur 1


App.h


#include <QApplication>

#ifndef APP
#define APP

/*!
* \class App
*/
class App
{
private:

Frm *theFrm;
//public: void App ( void );


/*!
* \fn virtual bool OnInit( void );
* \brief Inits the Application
*/
virtual bool OnInit( void );
};

#endif


App.cpp


#include "../src/Frm.cpp"

#include "../inc/App.h"

IMPLEMENT_APP( App )



bool App::OnInit( void )
{
theFrm = new Frm( );

return true;
}




Thx

vieraci
30th May 2009, 05:03
You have not declared a default constructor.

chochatown
30th May 2009, 21:22
exuse i declared it before and it dont work that's new declaration:

App.cpp

#include "../src/Frm.cpp"

#include "../inc/App.h"

IMPLEMENT_APP( App )

App::App( void )
{}

bool App::OnInit( void )
{
theFrm = new Frm( );

return true;
}


App.h


class App
{
private:

Frm *theFrm;
public: App ( void );


/*!
* \fn virtual bool OnInit( void );
* \brief Inits the Application
*/
virtual bool OnInit( void );

};

#endif




and that's teh error egain :

make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/local/include -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -Isrc -Iinc -I. -I. -o App.o src/App.cpp
src/App.cpp:41: erreur: expected constructor, destructor, or type conversion before «App»
make: *** [App.o] Erreur 1

faldzip
30th May 2009, 22:15
First of all: use the [ CODE ] tags!

In your App.h there is no line decalring, or defining Frm type, so the error is because you use Frm and compiler doesn't know what is that. So include the header file with Frm declaration to your App.h, or make the forward declaration:


#include <QApplication>

#ifndef APP
#define APP

class Frm;
/*!
* \class App
*/
class App
{
// . . .

P.S. Remember about CODE tags, without them it's really hard to read your code and in my opinion without CODE tags with so many doxygen comments it's much harder to see anything in your code.