Du bist nicht angemeldet.

Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!

Werbeanzeige

1

19.04.2013, 18:33

[ C++ ] Problem mit Konstruktoraufruf in abgeleiteter Klasse

Moin Leute,

habe grade ein Problem mit dem Konstruktoraufruf meiner AdvancedSprite Klasse.

C-/C++-Quelltext

1
2
3
4
5
6
7
8
//_______ADVANCEDSPRITE_H_______//

class AdvancedSprite : public Animateable
{

public:
    AdvancedSprite( AnimationSettings ani_settings ) : Animateable( ani_settings );
};


C-/C++-Quelltext

1
2
3
4
5
6
//_______ADVANCEDSPRITE_CPP_______//

AdvancedSprite::AdvancedSprite( AnimationSettings ani_settings ) : Animateable( ani_settings )
{

};


C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
//_______ANIMATEABLE_H_______//


class Animateable : public sf::Sprite
{

public:
    Animateable( AnimationSettings ani_settings );

};


C-/C++-Quelltext

1
2
3
4
5
6
7
//_______ANIMATEABLE_CPP_______//


Animateable::Animateable( AnimationSettings ani_settings )
{

};


Wenn ich das Programm so ausführen möchte, bekomme ich einige Fehlermeldungen:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
18 IntelliSense: Es wurde eine "{" erwartet. c:\Users\Kay\Desktop\Visual Studio\Projekte\The Castaway Adventure II\The Castaway Adventure II\AdvancedSprite.h 13 80 The Castaway Adventure II
Fehler 1 error C2969: Syntaxfehler: ';': Definition der Memberfunktion endet nicht mit '}' c:\users\kay\desktop\visual studio\projekte\the castaway adventure ii\the castaway adventure ii\AdvancedSprite.h 13 1 The Castaway Adventure II
Fehler 13 error C2969: Syntaxfehler: ';': Definition der Memberfunktion endet nicht mit '}' c:\users\kay\desktop\visual studio\projekte\the castaway adventure ii\the castaway adventure ii\AdvancedSprite.h 13 1 The Castaway Adventure II
Fehler 5 error C2630: ';' in Liste gefunden, aber durch Trennzeichen getrennte Liste erforderlich C:\Users\Kay\Desktop\Visual Studio\Projekte\The Castaway Adventure II\The Castaway Adventure II\AdvancedSprite.cpp 6 1 The Castaway Adventure II
Fehler 15 error C2630: ';' in Liste gefunden, aber durch Trennzeichen getrennte Liste erforderlich C:\Users\Kay\Desktop\Visual Studio\Projekte\The Castaway Adventure II\The Castaway Adventure II\main.cpp 9 1 The Castaway Adventure II
Fehler 7 error C2614: 'AdvancedSprite': Unzulässige Elementinitialisierung: 'AdvancedSprite' ist weder Basis noch Element C:\Users\Kay\Desktop\Visual Studio\Projekte\The Castaway Adventure II\The Castaway Adventure II\AdvancedSprite.cpp 6 1 The Castaway Adventure II
Fehler 6 error C2612: Abschließendes 'Bezeichner' in Initialisierungsliste für Basisklasse/Elemente nicht zulässig C:\Users\Kay\Desktop\Visual Studio\Projekte\The Castaway Adventure II\The Castaway Adventure II\AdvancedSprite.cpp 6 1 The Castaway Adventure II
Fehler 11 error C2601: 'AdvancedSprite::update': Lokale Funktionsdefinitionen sind unzulässig C:\Users\Kay\Desktop\Visual Studio\Projekte\The Castaway Adventure II\The Castaway Adventure II\AdvancedSprite.cpp 17 1 The Castaway Adventure II
Fehler 17 error C2562: 'AdvancedSprite::AdvancedSprite': 'void'-Funktion gibt einen Wert zurück C:\Users\Kay\Desktop\Visual Studio\Projekte\The Castaway Adventure II\The Castaway Adventure II\main.cpp 69 1 The Castaway Adventure II
Fehler 16 error C2534: 'AdvancedSprite': Konstruktor kann kein Ergebnis zurückgeben C:\Users\Kay\Desktop\Visual Studio\Projekte\The Castaway Adventure II\The Castaway Adventure II\main.cpp 69 1 The Castaway Adventure II
Fehler 3 error C2275: 'AnimationSettings': Ungültige Verwendung dieses Typs als Ausdruck C:\Users\Kay\Desktop\Visual Studio\Projekte\The Castaway Adventure II\The Castaway Adventure II\AdvancedSprite.cpp 6 1 The Castaway Adventure II
Fehler 4 error C2146: Syntaxfehler: Fehlendes ')' vor Bezeichner 'ani_settings' C:\Users\Kay\Desktop\Visual Studio\Projekte\The Castaway Adventure II\The Castaway Adventure II\AdvancedSprite.cpp 6 1 The Castaway Adventure II
Fehler 9 error C2143: Syntaxfehler: Es fehlt ';' vor '{' C:\Users\Kay\Desktop\Visual Studio\Projekte\The Castaway Adventure II\The Castaway Adventure II\AdvancedSprite.cpp 6 1 The Castaway Adventure II
Fehler 10 error C2143: Syntaxfehler: Es fehlt ';' vor '{' C:\Users\Kay\Desktop\Visual Studio\Projekte\The Castaway Adventure II\The Castaway Adventure II\AdvancedSprite.cpp 12 1 The Castaway Adventure II
Fehler 14 error C2062: 'int'-Typ unerwartet C:\Users\Kay\Desktop\Visual Studio\Projekte\The Castaway Adventure II\The Castaway Adventure II\main.cpp 8 1 The Castaway Adventure II
Fehler 8 error C2059: Syntaxfehler: ')' C:\Users\Kay\Desktop\Visual Studio\Projekte\The Castaway Adventure II\The Castaway Adventure II\AdvancedSprite.cpp 6 1 The Castaway Adventure II
Fehler 2 error C2039: '{ctor}': Ist kein Element von 'AdvancedSprite' C:\Users\Kay\Desktop\Visual Studio\Projekte\The Castaway Adventure II\The Castaway Adventure II\AdvancedSprite.cpp 6 1 The Castaway Adventure II
Fehler 12 error C1004: Unerwartetes Dateiende gefunden. C:\Users\Kay\Desktop\Visual Studio\Projekte\The Castaway Adventure II\The Castaway Adventure II\AdvancedSprite.cpp 20 1 The Castaway Adventure II


Dann habe ich den Konstruktor von AdvancedSprite in der header definiert und die Definition in der AdvancedSprite.cpp gelöscht.

C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
//_______ADVANCEDSPRITE_H_______//


class AdvancedSprite : public Animateable
{

public:
    AdvancedSprite( AnimationSettings ani_settings ) : Animateable( ani_settings ){};
    ~AdvancedSprite();

    void update();
};


Und siehe da. Es klappt. :D
Aber wiso funktioniert es in der AdvancedSprite.cpp nicht ?(

Mit freundlichen Grüßen,
Maxo

BlueCobold

Community-Fossil

Beiträge: 10 738

Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer

  • Private Nachricht senden

2

19.04.2013, 19:00

Entweder Du schreibst eine Definition inklusive Initializer-Liste oder Du schreibst nur eine Deklaration ohne. Aber kein Misch-Masch daraus.

Darauf hättest Du aber eigentlich kommen können, denn:
"Es wurde eine "{" erwartet"
Teamleiter von Rickety Racquet (ehemals das "Foren-Projekt") und von Marble Theory

Willkommen auf SPPRO, auch dir wird man zu Unity oder zur Unreal-Engine raten, ganz bestimmt.[/Sarkasmus]

3

19.04.2013, 20:17

Jetzt hats geklappt.

Danke für die schnelle Antwort :thumbsup:

Mfg
Maxo

Werbeanzeige