Superkonstruktor wie in Java



  • ok ich hab oben ein #include "main.cpp" eingefügt.

    die fehler von vorhin sind weg, aber jetzt sind noch viel mehr neue Fehler entstanden 😮

    mein Compiler sagt:
    In file included from ui_alert.h:18,
    from main.cpp:9:
    main.cpp:68: error: using-declaration for non-member at class scope
    main.cpp:68: error: expected ;' before "alert" main.cpp: In member functionvoid Funktionen::getPath()':
    main.cpp:160: error: alert' undeclared (first use this function) main.cpp:160: error: (Each undeclared identifier is reported only once for each function it appears in.) main.cpp: In member functionvoid Funktionen::date_of_ini()':
    main.cpp:210: error: alert' undeclared (first use this function) main.cpp: In member functionvoid Funktionen::date_of_template()':
    main.cpp:306: error: alert' undeclared (first use this function) main.cpp: In member functionvoid Funktionen::files_available()':
    main.cpp:415: error: alert' undeclared (first use this function) main.cpp: In member functionvoid Funktionen::displayGUI()':
    main.cpp:566: error: alert' undeclared (first use this function) main.cpp: In constructorFunktionen::Funktionen()':
    main.cpp:587: error: alert' undeclared (first use this function) In file included from main.cpp:9: ui\_alert.h: In member functionvoid Ui_AlertWindow::ok()':
    ui_alert.h:32: error: 'class Funktionen' has no member named 'ausfuehren'
    ui_alert.h: At global scope:
    ui_alert.h:177: error: base Ui\_AlertWindow' with only non-default constructor in class without a constructor main.cpp:21: error: redefinition ofclass Funktionen'
    main.cpp:21: error: previous definition of class Funktionen' main.cpp: In functionint qMain(int, char**)':
    main.cpp:73: error: redefinition of int qMain(int, char**)' main.cpp:73: error:int qMain(int, char**)' previously defined here
    main.cpp: At global scope:
    main.cpp:155: error: redefinition of void Funktionen::getPath()' main.cpp:155: error:void Funktionen::getPath()' previously defined here
    main.cpp: In member function void Funktionen::getPath()': main.cpp:160: error:alert' undeclared (first use this function)
    main.cpp: At global scope:
    main.cpp:196: error: redefinition of void Funktionen::date\_of\_ini()' main.cpp:196: error:void Funktionen::date_of_ini()' previously defined here
    main.cpp: In member function void Funktionen::date\_of\_ini()': main.cpp:210: error:alert' undeclared (first use this function)
    main.cpp: At global scope:
    main.cpp:292: error: redefinition of void Funktionen::date\_of\_template()' main.cpp:292: error:void Funktionen::date_of_template()' previously defined here
    main.cpp: In member function void Funktionen::date\_of\_template()': main.cpp:306: error:alert' undeclared (first use this function)
    main.cpp: At global scope:
    main.cpp:396: error: redefinition of void Funktionen::files_available()' main.cpp:396: error:void Funktionen::files_available()' previously defined here
    main.cpp: In member function void Funktionen::files_available()': main.cpp:415: error:alert' undeclared (first use this function)
    main.cpp: At global scope:
    main.cpp:425: error: redefinition of void Funktionen::getServerName\_and\_IP()' main.cpp:425: error:void Funktionen::getServerName_and_IP()' previously defined here
    main.cpp:501: error: redefinition of void Funktionen::showServerName()' main.cpp:501: error:void Funktionen::showServerName()' previously defined here
    main.cpp:515: error: redefinition of void Funktionen::get\_Path\_of_App()' main.cpp:515: error:void Funktionen::get_Path_of_App()' previously defined here
    main.cpp:528: error: redefinition of void Funktionen::unrar()' main.cpp:528: error:void Funktionen::unrar()' previously defined here
    main.cpp:557: error: redefinition of void Funktionen::setArray()' main.cpp:557: error:void Funktionen::setArray()' previously defined here
    main.cpp:565: error: redefinition of void Funktionen::displayGUI()' main.cpp:565: error:void Funktionen::displayGUI()' previously defined here
    main.cpp: In member function void Funktionen::displayGUI()': main.cpp:566: error:alert' undeclared (first use this function)
    main.cpp: At global scope:
    main.cpp:585: error: redefinition of Funktionen::Funktionen()' main.cpp:585: error:Funktionen::Funktionen()' previously defined here
    main.cpp: In constructor Funktionen::Funktionen()': main.cpp:587: error:alert' undeclared (first use this function)
    main.cpp: At global scope:
    main.cpp:593: error: redefinition of Funktionen::~Funktionen()' main.cpp:593: error:Funktionen::~Funktionen()' previously defined here

    also wie ich sehe kann ich es vergessen.oder was soll ich machen?



  • Neeeiiiin!
    Du sollst keine cpp und schon garnicht die main.cpp inkludieren. Lagere die Deklaration der Klasse Funktionen in eine Headerdatei aus und inkludiere die.
    Ich habe das Gefühl, du solltest dir nochmal ein Tutorial zu diesen Themen durchlesen bevor du mit QT weitermachen willst. Ist jetzt nicht böse gemeint.



  • ok. da hast du wohl recht. kennst du vielleicht ein gutes tutorial dazu. ich hab grad eben bischen gegooglet, aber nichts tolles gefunden.





  • ok. habs ich jetzt gemacht. der compiler sagtt jetzt folgendes:
    In file included from ui_alert.h:18,
    from main.cpp:9:
    funktionen.h:39: error: using-declaration for non-member at class scope
    funktionen.h:39: error: expected ;' before "alert" In file included from main.cpp:9: ui\_alert.h:172: error: baseUi_AlertWindow' with only non-default constructor in class without a constructor
    mingw32-make: *** [release\main.o] Error 1

    39: Ui::AlertWindow alert;
    172: class AlertWindow: public Ui_AlertWindow {};

    kann mir das jemand erklären? oder sagen was ich tun soll?



  • 39
    funktionen.h scheint Ui::AlertWindow nicht zu kennen. Mach diese Klasse bekannt. Was ist denn Ui, ein namespace?
    172

    class AlertWindow: public Ui_AlertWindow {};
    

    Hier deklarierst du die Klasse AlertWindow abgeleitet von Ui_AlertWindow ohne einen neuen Konstruktor zu deklarieren. Der Compiler versucht dann den default-Konstruktor zu erzeugen. Dieser muß den default-Konstruktor der Basisklasse Ui_AlertWindow aufrufen. Diese hat aber keinen, da dort ein nicht-default-Konstruktor existiert.
    Entweder du spendierst der Basisklasse einen Default-Konstruktor (ohne Argumente) oder du deklarierst in AlertWindow einen eigenen Konstruktor welcher den Konstruktor der Basisklasse aufruft.


Anmelden zum Antworten