Fehlermeldung C2084: Wieso? Hilfe!



  • Hallo, ich muss ein Programm schreiben indem Lieder (inklusive: interpret, album, jahr, genre...) abgespeichert (als c-strings) und ausgegeben werden.
    Ich bin relativ weit gekommen, aber kriege diese Fehlermeldung nicht weg:
    Fehlererror C2084: Funktion 'id3v1tag eingabe_id3v1Tag(void)' hat bereits einen Funktionsrumpf

    mir ist nichtmal ganz klar was der fehler genau bedeuten soll, da ich ja nur einen rumpf unter der funktion habe.
    muss hierzu aber auch sagen dass ich erst seit kurzer zeit angefangen habe zu programmieren
    Freue mich sehr über hilfreiche antworten. 🙂

    main.cpp

    #include <iostream>
    #include "eingabefunktion.h";
    #include "Interpretsuche.h";
    #include "Struktur.h";
    #include <string>
    using namespace std;
    
    int main()
    {
    	int eingabe;
    	string interpretsuche;
    	struct id3v1tag titel[250];
    
    	id3v1tag*anker = nullptr;
    
    	do {
    		cout << "t - Titel eingeben \n" << "i - Interpret suchen \n" << "e - Programmende \n";
    		cin >> eingabe;
    
    		if (eingabe == 't')
    		{
    			struct id3v1tag eingabe_id3v1Tag();
    
    		}
    		else if (eingabe == 'i')
    		{
    			cout << "Interpret = ? ";
    			cin >> interpretsuche;
    
    			void suche_interpret(struct id3v1tag
    				titel[250], char interpret[30], int n);
    
    		}
    		else if (eingabe == 'e')
    		{
    			break;
    		}
    	} while (eingabe != 'e');
    
    	system("PAUSE");
    	return 0;
    
    }
    

    struktur.h

    #pragma once
    
    struct id3v1tag
    
    {	char trackname[30];
    	char interpret[30];
    	char album[30];
    	char jahr[4]; //Vorgabe: kein nullterminierungszeichen
    	char kommentar[30];
    	unsigned char genre[2];
    };
    

    eingabefunktion.h

    #include <iostream>
    #include "Struktur.h"
    #include "Interpretsuche.h";
    using namespace std;
    
    # pragma once
    
    struct id3v1tag eingabe_id3v1Tag()
    {
    	char trackname[30] = { 0 };
    	char interpret[30] = { 0 };
    	char album[30] = { 0 };
    	int jahr;
    	char kommentar[30] = { 0 };
    	int genre;
    	char eingabe;
    	char interpretsuche[30] = { 0 };
    
    			cout << "Eingabe: \n" << "Track = ? ";
    			cin >> trackname;
    			cout << "Interpret = ? ";
    			cin >> interpret;
    			cout << "Album = ? ";
    			cin >> album;
    			cout << "Jahr = ? ";
    			cin >> jahr;
    			cout << "Kommentar = ? ";
    			cin >> kommentar;
    			cout << "Genre = ? ";
    			cin >> genre;
    			unsigned char(genre);
    
    }
    

    interpretsuche.h

    #include <iostream>
    # pragma once 
    #include "eingabefunktion.h"
    #include "genres.h"
    
    using namespace std;
    
    void suche_interpret(struct id3v1tag titel[250], char interpret[30], int n)
    {
    	for (int i = 1; i <= n; i++)
    		{
    
    			if (strcmp(titel[i].interpret, interpret) == 0)
    			{
    
    				cout << "Titel Nr. " << i << endl
    					<< titel[i].trackname << endl
    					<< titel[i].interpret << endl
    					<< titel[i].album << endl
    					<< titel[i].jahr[0] << titel[i].jahr[1] << titel[i].jahr[2] << titel[i].jahr[3] << endl;
    
    				int a = int(titel[i].genre - 48);
    
    				cout << "Genre: " << genres[a][100] << endl << endl;
    			}
    
    		}
    	}
    

    genres.h

    #pragma once
    
    char genres[][100] = { { "Blues" }, { "Classic Rock" }, { "Country" }, { "Dance" }, { "Disco" },
    { "Funk" }, { "Grunge" }, { "Hip-Hop" }, { "Jazz" }, { "Metal" }, { "New Age" }, { "Oldies" },
    { "Other" }, { "Pop" }, { "R&B" }, { "Rap" }, { "Reggae" }, { "Rock" }, { "Techno" }, { "Industrial" },
    { "Alternative" }, { "Ska" }, { "Death Metal" }, { "Pranks" }, { "Soundtrack" }, { "Euro-Techno" },
    { "Ambient" }, { "Trip-Hop" }, { "Vocal" }, { "Jazz+Funk" }, { "Fusion" }, { "Trance" },
    { "Classical" }, { "Instrumental" }, { "Acid" }, { "House" }, { "Game" }, { "Sound Clip" },
    { "Gospel" }, { "Noise" }, { "Alternative Rock" }, { "Bass" }, { "Soul" }, { "Punk" }, { "Space" },
    { "Meditative" }, { "Instrumental Pop" }, { "Instrumental Rock" }, { "Ethnic" }, { "Gothic" },
    { "Darkwave" }, { "Techno-Industrial" }, { "Electronic" }, { "Pop-Folk" }, { "Eurodance" },
    { "Dream" }, { "Southern Rock" }, { "Comedy" }, { "Cult" }, { "Gangsta" }, { "Top 40" },
    { "Christian Rap" }, { "Pop/Funk" }, { "Jungle" }, { "Native US" }, { "Cabaret" }, { "New Wave" },
    { "Psychadelic" }, { "Rave" }, { "Showtunes" }, { "Trailer" }, { "Lo-Fi" }, { "Tribal" }, { "Acid Punk" }, { "Acid Jazz" }, { "Polka" }, { "Retro" }, { "Musical" }, { "Rock & Roll" },
    { "Hard Rock" }, { "Folk" }, { "Folk - Rock" }, { "National Folk" }, { "Swing" }, { "Fast Fusion" },
    { "Bebob" }, { "Latin" }, { "Revival" }, { "Celtic" }, { "Bluegrass" }, { "Avantgarde" }, { "Gothic Rock" }, { "Progressive Rock" }, { "Psychedelic Rock" }, { "Symphonic Rock" }, { "Slow Rock" },
    { "Big Band" }, { "Chorus" }, { "Easy Listening" }, { "Acoustic" }, { "Humour" }, { "Speech" },
    { "Chanson" }, { "Opera" }, { "Chamber Music" }, { "Sonata" }, { "Symphony" }, { "Booty Bass" },
    { "Primus" }, { "Porn Groove" }, { "Satire" }, { "Slow Jam" }, { "Club" }, { "Tango" }, { "Samba" },
    { "Folklore" }, { "Ballad" }, { "Power Ballad" }, { "Rhythmic Soul" }, { "Freestyle" }, { "Duet" },
    { "Punk Rock" }, { "Drum Solo" }, { "A Cappella" }, { "Euro-House" }, { "Dance Hall" }, { "Goa" },
    { "Drum & Bass" }, { "Club-House" }, { "Hardcore" }, { "Terror" }, { "Indie" }, { "BritPop" },
    { "Negerpunk" }, { "Polsk Punk" }, { "Beat" }, { "Christian Gangsta Rap" }, { "Heavy Metal" },
    { "Black Metal" }, { "Crossover" }, { "Contemporary Christian" }, { "Christian Rock" },
    { "Merengue" }, { "Salsa" }, { "Thrash Metal" }, { "Anime" }, { "JPop" }, { "Synthpop" }, { "" } };
    


  • newling987 schrieb:

    mir ist nichtmal ganz klar was der fehler genau bedeuten soll, da ich ja nur einen rumpf unter der funktion habe.

    Tja, im Programm schon, aber der Präprozessor fügt die Dateien ja bei den #include-Direktiven (übrigens: ohne Semikolon am Ende!) ein, so dass die Funktion bei dir anscheinend insgesamt zweimal eingebunden wird.

    Ich weiß ja nicht, wie und womit du C++ lernst, aber wenn dir das da so beigebracht wird, solltest du kritisch sein. Definitionen von Funktionen und Variablen gehören nicht in Headerfiles, sondern in eigene cpp-Files.



  • Du verletzt die One Definition Rule (ODR).
    eingabe_id3v1Tag wird im Header definiert, diesen inkludierst du mehrfach.
    Lösung definiere die Funktion in einer cpp Datei, vorzugsweise einer neuen eingabefunktion.cpp.

    Und auch sonst ist an deinem Programm einiges komisch:
    Zeile 31f. z.B.
    Oder die Tatsache, dass du Char-Arrays anstatt std::string nutzt.
    Oder Strukturen mit struct kennzeichnest.
    Das sieht mehr nach C aus. Wie genau lernst du C++?



  • Nathan : es war die vorgabe gemacht, dass wir c-strings also char arrays benutzen sollen und keine strings und auch das mit den strukturen 😕

    Bashar : ah ok, voll verplant 😕



  • newling987 schrieb:

    Nathan : es war die vorgabe gemacht, dass wir c-strings also char arrays benutzen sollen und keine strings und auch das mit den strukturen 😕

    Ups sorry.
    Trotzdem stimmen die anderen Punkte.
    Und an struct ist grundsätzlich nichts falsch, ich meinte nur dass du struct id3v1tag eingabe_id3v1Tag() geschrieben hast, dort ist das struct (in C++) überflüssig.



  • [quote] Nathan : auch die vorgabe wurde gemacht, dass man so eine funktion schreiben soll 😕 mir ist der nutzen auch nicht ganz klar...

    mein Programm sieht verändert nun so aus:

    main.cpp

    #include <iostream>
    #include "eingabefunktion.h"
    #include "Interpretsuche.h"
    #include "Struktur.h"
    #include <string>
    using namespace std;
    
    char genres[][100] = { { "Blues" }, { "Classic Rock" }, { "Country" }, { "Dance" }, { "Disco" },
    { "Funk" }, { "Grunge" }, { "Hip-Hop" }, { "Jazz" }, { "Metal" }, { "New Age" }, { "Oldies" },
    { "Other" }, { "Pop" }, { "R&B" }, { "Rap" }, { "Reggae" }, { "Rock" }, { "Techno" }, { "Industrial" },
    { "Alternative" }, { "Ska" }, { "Death Metal" }, { "Pranks" }, { "Soundtrack" }, { "Euro-Techno" },
    { "Ambient" }, { "Trip-Hop" }, { "Vocal" }, { "Jazz+Funk" }, { "Fusion" }, { "Trance" },
    { "Classical" }, { "Instrumental" }, { "Acid" }, { "House" }, { "Game" }, { "Sound Clip" },
    { "Gospel" }, { "Noise" }, { "Alternative Rock" }, { "Bass" }, { "Soul" }, { "Punk" }, { "Space" },
    { "Meditative" }, { "Instrumental Pop" }, { "Instrumental Rock" }, { "Ethnic" }, { "Gothic" },
    { "Darkwave" }, { "Techno-Industrial" }, { "Electronic" }, { "Pop-Folk" }, { "Eurodance" },
    { "Dream" }, { "Southern Rock" }, { "Comedy" }, { "Cult" }, { "Gangsta" }, { "Top 40" },
    { "Christian Rap" }, { "Pop/Funk" }, { "Jungle" }, { "Native US" }, { "Cabaret" }, { "New Wave" },
    { "Psychadelic" }, { "Rave" }, { "Showtunes" }, { "Trailer" }, { "Lo-Fi" }, { "Tribal" }, { "Acid Punk" }, { "Acid Jazz" }, { "Polka" }, { "Retro" }, { "Musical" }, { "Rock & Roll" },
    { "Hard Rock" }, { "Folk" }, { "Folk - Rock" }, { "National Folk" }, { "Swing" }, { "Fast Fusion" },
    { "Bebob" }, { "Latin" }, { "Revival" }, { "Celtic" }, { "Bluegrass" }, { "Avantgarde" }, { "Gothic Rock" }, { "Progressive Rock" }, { "Psychedelic Rock" }, { "Symphonic Rock" }, { "Slow Rock" },
    { "Big Band" }, { "Chorus" }, { "Easy Listening" }, { "Acoustic" }, { "Humour" }, { "Speech" },
    { "Chanson" }, { "Opera" }, { "Chamber Music" }, { "Sonata" }, { "Symphony" }, { "Booty Bass" },
    { "Primus" }, { "Porn Groove" }, { "Satire" }, { "Slow Jam" }, { "Club" }, { "Tango" }, { "Samba" },
    { "Folklore" }, { "Ballad" }, { "Power Ballad" }, { "Rhythmic Soul" }, { "Freestyle" }, { "Duet" },
    { "Punk Rock" }, { "Drum Solo" }, { "A Cappella" }, { "Euro-House" }, { "Dance Hall" }, { "Goa" },
    { "Drum & Bass" }, { "Club-House" }, { "Hardcore" }, { "Terror" }, { "Indie" }, { "BritPop" },
    { "Negerpunk" }, { "Polsk Punk" }, { "Beat" }, { "Christian Gangsta Rap" }, { "Heavy Metal" },
    { "Black Metal" }, { "Crossover" }, { "Contemporary Christian" }, { "Christian Rock" },
    { "Merengue" }, { "Salsa" }, { "Thrash Metal" }, { "Anime" }, { "JPop" }, { "Synthpop" }, { "" } };
    
    int n=0;
    
    int main()
    {
    
    	char eingabe;
    	string interpretsuche;
    	struct id3v1tag titel[250];
    
    	id3v1tag*anker = nullptr;
    
    	do {
    		cout << "t - Titel eingeben \n" << "i - Interpret suchen \n" << "e - Programmende \n";
    		cin >> eingabe;
    
    		if (eingabe == 't')
    		{
    			n++;
    			struct id3v1tag eingabe_id3v1Tag();
    			for (int i = 0; i < 250; i++)
    				titel[i];
    
    		}
    		if (eingabe == 'i')
    		{
    			cout << "Interpret = ? ";
    			cin >> interpretsuche;
    
    			void suche_interpret(struct id3v1tag
    				titel[250], char interpret[30], int n);
    
    		}
    		if (eingabe == 'e')
    			break;
    
    	} while (true);
    
    	system("PAUSE");
    	return 0;
    
    }
    

    eingabefunktion.cpp

    #include <iostream>
    #include "Struktur.h"
    #include <string>
    using namespace std;
    
    struct id3v1tag titel[250];
    
    struct id3v1tag eingabe_id3v1Tag()
    {
    	int n=0;
    	string track_eingabe;
    	string interpret_eingabe;
    	string album_eingabe;
    	string jahr_eingabe;
    	string kommentar_eingabe;
    	string genre_eingabe;
    	string eingabe;
    	string interpretsuche[30] = { 0 };
    
    	cout << "Eingabe: \n" << "Track = ? ";
    	cin >> track_eingabe;
    	cout << "Interpret = ? ";
    	cin >> interpret_eingabe;
    	cout << "Album = ? ";
    	cin >> album_eingabe;
    	cout << "Jahr = ? ";
    	cin >> jahr_eingabe;
    	cout << "Kommentar = ? ";
    	cin >> kommentar_eingabe;
    	cout << "Genre = ? ";
    	cin >> genre_eingabe;
    
    	//Speicherung in struct id3v1tag:
    	for (int i = 0; i < track_eingabe.length(); i++)
    		titel[n].trackname[i] = track_eingabe.at(i);
    
    	for (int i = 0; i < interpret_eingabe.length(); i++)
    		titel[n].interpret[i] = interpret_eingabe.at(i);
    
    	for (int i = 0; i < album_eingabe.length(); i++)
    		titel[n].album[i] = album_eingabe.at(i);
    
    	for (int i = 0; i < kommentar_eingabe.length(); i++)
    		titel[n].kommentar[i] = kommentar_eingabe.at(i);
    
    	for (int i = 0; i < jahr_eingabe.length(); i++)
    		titel[n].jahr[i] = jahr_eingabe.at(i);
    
    	for (int i = 0; i < genre_eingabe.length(); i++)
    		titel[n].genre[i] = genre_eingabe.at(i);
    
    	return  titel[n];
    
    }
    

    eingabefunktion.h

    # pragma once
    
    struct id3v1tag eingabe_id3v1Tag();
    

    interpretsuche.cpp

    #include <iostream>
    #include "Struktur.h"
    using namespace std;
    
    char genres[][100];
    
    void suche_interpret(struct id3v1tag titel[250], char interpret[30], int n)
    {
    	for (int i = 1; i <= n; i++)
    	{
    		//Vergleich
    		if (strcmp(titel[i].interpret, interpret) == 0)
    		{
    
    			cout << "Titel Nr. " << i << endl
    				<< titel[i].trackname << endl
    				<< titel[i].interpret << endl
    				<< titel[i].album << endl
    				<< titel[i].jahr[0] << titel[i].jahr[1] << titel[i].jahr[2] << titel[i].jahr[3] << endl;
    
    			int a = int(titel[i].genre - 48);
    			cout << genres[a][100] << endl << endl;
    		}
    
    	}
    }
    

    Interpretsuche.h

    # pragma once
    
    void suche_interpret(struct id3v1tag titel[250], char interpret[30], int n);
    

    Struktur.h

    #pragma once
    
    struct id3v1tag
    {	char trackname[30];
    	char interpret[30];
    	char album[30];
    	char jahr[4]; //Vorgabe: kein nullterminierungszeichen
    	char kommentar[30];
    	unsigned char genre[2];
    };
    

    Das Programm compiliert zwar und startet, jedoch steigt es nicht in die eingabefunktion ein (wenn man "t" (siehe main.cpp) auswählt), sondern stellt die abfrage (ob man t,i oder e wählen will) erneut!
    Ich stelle mal die vermutung dass auch noch andere fehler vorhanden sein könnten... 🤡
    freue mich über tipps und hinweise



  • struct id3v1tag eingabe_id3v1Tag();
    
    void suche_interpret(struct id3v1tag
                    titel[250], char interpret[30], int n);
    

    So ruft man keine Funktionen auf. Lies dir das entsprechende Material dazu noch mal durch.
    Oder besser: Kauf dir eines der Bücher, das die Leute hier vorschlagen.

    P.S:

    titel[i];
    

    Das macht nichts.



  • Wieso kompelliert das überhaupt? (Ernst gemeinte Frage)



  • hab mein funktion-aufruf-teil nun verändert:

    main.cpp

    #include <iostream>
    #include "eingabefunktion.h"
    #include "Interpretsuche.h"
    #include "Struktur.h"
    #include <string>
    using namespace std;
    
    char genres[][100] = { { "Blues" }, { "Classic Rock" }, { "Country" }, { "Dance" }, { "Disco" },
    { "Funk" }, { "Grunge" }, { "Hip-Hop" }, { "Jazz" }, { "Metal" }, { "New Age" }, { "Oldies" },
    { "Other" }, { "Pop" }, { "R&B" }, { "Rap" }, { "Reggae" }, { "Rock" }, { "Techno" }, { "Industrial" },
    { "Alternative" }, { "Ska" }, { "Death Metal" }, { "Pranks" }, { "Soundtrack" }, { "Euro-Techno" },
    { "Ambient" }, { "Trip-Hop" }, { "Vocal" }, { "Jazz+Funk" }, { "Fusion" }, { "Trance" },
    { "Classical" }, { "Instrumental" }, { "Acid" }, { "House" }, { "Game" }, { "Sound Clip" },
    { "Gospel" }, { "Noise" }, { "Alternative Rock" }, { "Bass" }, { "Soul" }, { "Punk" }, { "Space" },
    { "Meditative" }, { "Instrumental Pop" }, { "Instrumental Rock" }, { "Ethnic" }, { "Gothic" },
    { "Darkwave" }, { "Techno-Industrial" }, { "Electronic" }, { "Pop-Folk" }, { "Eurodance" },
    { "Dream" }, { "Southern Rock" }, { "Comedy" }, { "Cult" }, { "Gangsta" }, { "Top 40" },
    { "Christian Rap" }, { "Pop/Funk" }, { "Jungle" }, { "Native US" }, { "Cabaret" }, { "New Wave" },
    { "Psychadelic" }, { "Rave" }, { "Showtunes" }, { "Trailer" }, { "Lo-Fi" }, { "Tribal" }, { "Acid Punk" }, { "Acid Jazz" }, { "Polka" }, { "Retro" }, { "Musical" }, { "Rock & Roll" },
    { "Hard Rock" }, { "Folk" }, { "Folk - Rock" }, { "National Folk" }, { "Swing" }, { "Fast Fusion" },
    { "Bebob" }, { "Latin" }, { "Revival" }, { "Celtic" }, { "Bluegrass" }, { "Avantgarde" }, { "Gothic Rock" }, { "Progressive Rock" }, { "Psychedelic Rock" }, { "Symphonic Rock" }, { "Slow Rock" },
    { "Big Band" }, { "Chorus" }, { "Easy Listening" }, { "Acoustic" }, { "Humour" }, { "Speech" },
    { "Chanson" }, { "Opera" }, { "Chamber Music" }, { "Sonata" }, { "Symphony" }, { "Booty Bass" },
    { "Primus" }, { "Porn Groove" }, { "Satire" }, { "Slow Jam" }, { "Club" }, { "Tango" }, { "Samba" },
    { "Folklore" }, { "Ballad" }, { "Power Ballad" }, { "Rhythmic Soul" }, { "Freestyle" }, { "Duet" },
    { "Punk Rock" }, { "Drum Solo" }, { "A Cappella" }, { "Euro-House" }, { "Dance Hall" }, { "Goa" },
    { "Drum & Bass" }, { "Club-House" }, { "Hardcore" }, { "Terror" }, { "Indie" }, { "BritPop" },
    { "Negerpunk" }, { "Polsk Punk" }, { "Beat" }, { "Christian Gangsta Rap" }, { "Heavy Metal" },
    { "Black Metal" }, { "Crossover" }, { "Contemporary Christian" }, { "Christian Rock" },
    { "Merengue" }, { "Salsa" }, { "Thrash Metal" }, { "Anime" }, { "JPop" }, { "Synthpop" }, { "" } };
    
    int n=0;
    char interpret[30];
    
    int main()
    {
    
    	char eingabe;
    	struct id3v1tag titel[250];
    
    	id3v1tag*anker = nullptr;
    
    	do {
    		cout << "t - Titel eingeben \n" << "i - Interpret suchen \n" << "e - Programmende \n";
    		cin >> eingabe;
    
    		if (eingabe == 't')
    		{
    			n++;
    			eingabe_id3v1Tag();
    		}
    		if (eingabe == 'i')
    		{
    			cout << "Interpret = ? ";
    			cin >> interpret;
    
    			suche_interpret(titel, interpret, n);
    
    		}
    		if (eingabe == 'e')
    			break;
    
    	} while (true);
    
    	system("PAUSE");
    	return 0;
    
    }
    

    Das mit der eingabe-funktion klappt nun, jedoch steigt das programm nicht in die interpret_suche-funktion ein!
    Kann mir jemand sagen woran das liegt genau? 🙂



  • Sorry aber ich krieg ziemlich Kopfschmerzen wenn ich mir das durchlese.

    Darf man fragen welche Mittel Du zum Lernen verwendest? Irgendwie ist da keine Wissenstruktur zu erkennen bei Dir.

    So ziemlich alles in deinem Code ist eine Baustelle.

    Ich kann Dir genaures sagen, wenn ich wieder daheim bin, aber du solltest villeicht alles, was du bis jetzt geschrieben hast, noch einmal überdenken. Und villeicht währendessen auch noch mal in Ruhe dein Lehrmaterial durschauen.


Anmelden zum Antworten