Fehlerhafter Code? [wx]



  • Ich hab keine Idee, was an diesem Code nicht korrekt ist, aber ich bekomme einen Fehler in Zeile 5 und 19 (IMPLEMENT_APP & const wxChar) wonwegen
    "expected initializer before *"

    MfG

    Code:

    //base.cpp
    #include <wx/wx.h>
    #include "base.h"
    
    IMPLEMENT_APP(iApp)
    
    bool iApp::OnInit()
    {
    iFrame *frame = new iFrame
    (
    wxT("Hi all"), 50, 50, 200, 100
    );
    frame->Show(TRUE);
    SetTopWindow(frame);
    return TRUE;
    }
    
    iFrame::iFrame
    const wxChar *title,
    int xpos, int ypos,
    int width, int height
    ): wxFrame ( (wxFrame *) NULL, -1, title, wxPoint(xpos, ypos),
    wxSize(width, height), wxDEFAULT_FRAME_STYLE)
    {
    //Add a Panel
    wxPanel panel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxSize(200, 100);
    //Add a Button in de Panel
    wxButton button = new wxButton( panel wxID_OK, wxT("KK"), wxPoint(10, 10), wxDefaultSize);
    
    }
    
    //base.h
    #ifndef BASIC_H
    #define BASIC_H
    
    class iApp : public wxApp
    {
    	public:
    		virtual bool OnInit();
    }
    
    class iFrame : public wxFrame
    {
    	private:
    		wxPanel* panel;
    		wxButton* button;
    	public:
    	iFrame( const wxChar *title,
    			int xpos, int ypos,
    			int width, int height	);
        ~iFrame();
    }
    #endif
    


  • Hallo,

    im wxWidgets src-Paket gibts einen Ordner Samples.
    Den kann ich jedem immer empfehlen.

    Zu den Fehlern :

    Wo ist das DECLARE_APP ?
    Der Fehler Zeile 19, da fehlt eine Klammer ?
    In Zeile 28 fehlt ein Komma.

    Vergiss das mit den wxChar, normalerweise benutzt man wxString !
    Der ist auch implizit konvertierbar in wxChar.

    Sauberer Code hilft Fehler zu erkennen, anders formatiert würde dir das auch eher auffallen.



  • also in der .h ausserhalb der Klasse iApp machst du ein:

    DECLARE_APP(iApp)
    

    und in .cpp hinter iFrame::iFrame fehlt eine Klammer auf (Zeile 18)

    Update: Upps da war einer schneller....



  • dankesehr. funzt jetzt wie geplant.

    mfg


Anmelden zum Antworten