unbekanntes problem
-
das folgende programm will nicht kompilieren und ich weiß nicht warum:
#include <iostream> #include <string> #include <windows.h> #include <fstream> #include <stdlib.h> #include <conio.h> using namespace std; //globals string sol; char delim = '*'; string current; char ch; //FUNKTIONEN--------------- void eingabe() { cout<<"Please press a key to go on..."<<endl; FlushConsoleInputBuffer ( GetStdHandle ( STD_INPUT_HANDLE ) ); getch(); system("cls"); } void abfragen() { system("cls"); //lest die frage--------------- ifstream fin( "hallo.txt" ); getline(fin,current,'*'); cout<<"What's the english word for "<< current<<" ?"<<endl; //---------------------------- //fragt den benutzer--------- string que; cin>>que; //---------------------------- //lest die lösung-------------- getline(fin,sol,'*'); //------------------------------ //vergleicht lösung mit antwort--------- int right = sol.compare(que); if(right == 1 ) { cout<<"You suck"<<endl; } if(right == 0) { cout<<"You rock!"<<endl; } //-------------------------------------- } void hello() //begrüßung { cout<<" ___________________________________________________________ "<<endl; cout<<"|=================WELCOME TO #xLATIN v1.0===================|"<<endl; cout<<"| Copyright 2004 by master_tradiaz . all rights reserved.|"<<endl; cout<<"|___________________________________________________________|"<<endl; Sleep(2000); } void createf() { eingabe(); } void edit() { eingabe(); } void menu() //hauptmenü { static string exxit; cout<<" ___________________________________________________________ "<<endl; cout<<"| #x---L__A__T__I__N |"<<endl; cout<<"|>>>>>>>>>>>>>>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<<<<<<<<<<<<<<<<|"<<endl; cout<<"|<<<<<<<<<<<<<< MAIN_MENU >>>>>>>>>>>>>>>>|"<<endl; cout<<"|___________________________________________________________|"<<endl; cout<<" "<<endl; cout<<" ___________________________________________________________ "<<endl; cout<<"| KEY |"<<endl; cout<<"| 1 : Vocabltest //Test your vocable knowledge ! |"<<endl; cout<<"| 2 : Historical //Get asked historical questions ! |"<<endl; cout<<"|exit: quit //Exit #xLatin |"<<endl; cout<<"|___________________________________________________________|"<<endl; static string chosen; if (chosen != "exit") { cin>>chosen; } if(chosen == "1") { system("cls"); vocmenu(); menu(); } if(chosen == "2") { cout<<"hi2"<<endl; eingabe(); menu(); } if(chosen == "exit" ) { cout<<"Really quit #xLatin?(y/n):::"; cin>>exxit; if(exxit == "n") { chosen = ""; system("cls"); menu(); } else if(exxit == "y") { cout<<"Thanks for using #xLatin, please report bugs to www.xlatin-project.net.ms!"<<endl; eingabe(); exit(54878748678); } else if(exxit != "y" && exxit != "n") { cout<<"Please insert \"y\" to quit or \"n\" to leave #xLatin running"<<endl; chosen = "exit"; eingabe(); menu(); } } if(chosen != "1" && chosen != "2" && chosen != "exit" && chosen != "") { cout<<"sorry , function \""<< chosen <<"\" not available"<<endl; eingabe(); system("cls"); menu(); } } void vocmenu() { cout<<" ___________________________________________________________ "<<endl; cout<<"| KEY |"<<endl; cout<<"| 1 : Vocabletest //Test your vocable knowledge ! |"<<endl; cout<<"| 2 : Edit Chapter //Edit a vocable-chapter |"<<endl; cout<<"| 3 : Create chapter //Create a new vocable-chapter |"<<endl; cout<<"|main: main menu //Exit #xLatin |"<<endl; cout<<"|___________________________________________________________|"<<endl; string chosen; cin>>chosen; if (chosen == "1") { abfragen(); } else if (chosen == "2") { edit(); vocmenu(); } else if (chosen == "3") { createf(); vocmenu(); } else if (chosen == "main") { menu(); } else { cout<<"sorry , function \""<< chosen <<"\" not available"<<endl; eingabe(); system("cls"); vocmenu(); } } int main() { hello(); menu(); return 0; }
das ist die compiler-ausgabe:
F:\programmier tools\testit\main.cpp(191) : error C2065: 'vocmenu' : nichtdeklarierter Bezeichner
F:\programmier tools\testit\main.cpp(227) : warning C4305: 'argument' : Verkuerzung von 'const __int64' in 'int'
F:\programmier tools\testit\main.cpp(227) : warning C4309: 'argument' : Verkuerzung eines konstanten Wertes
F:\programmier tools\testit\main.cpp(264) : error C2373: 'vocmenu' : Neudefinition; unterschiedliche Modifizierer
Fehler beim Ausführen von cl.exe.testit.exe - 2 Fehler, 2 Warnung(en)
vocmenu() ist sehr wohl deklariert!
die warnungen sind unwichtig, die sind standartmäßig drin
hoffe ihr könnt mir helfen...
-
vocmenu ist deklariert, aber an der falschen stelle
Der Compiler compiliert deinen Quelltext von oben nach unten durch.
Erst definierst du menu(), worin vocmenu() verwendet wird, zu diesem Zeitpunt
aber kennt dein Compiler vocmenu() noch nicht und gibt einen entsprechenden Fehler aus.Zieh die vocmenu()-deklaration über die menu()-deklaration oder verwende
einen Prototyp über menu().
-
allerhöchsten dank!
genau das war das prolblem hab jetzt einen prototypen von vocmenu() gemacht!