学校向けのクイズプログラムを作成しようとしています。私のコードは次のとおりです
main.cpp:
#include <cmath>
#include <ctime>
#include <string>
#include "getQuestion.h"
using namespace std;
int main() {
int mainMenuChoice;
ifstream Bibliography;
//string easyBib;
ifstream easyBib;
ifstream inputFile;
cout << "Quiz Menu\n\n";
cout << "1. Play Game!\n";
cout << "2. Bibliography\n";
cout << "3. Developer Info\n";
//cout << "4. Admin Menu\n";
cout << "4. Exit\n";
cout << "Menu Choice: ";
cin >> mainMenuChoice;
switch (mainMenuChoice) {
case 1:
break;
case 2:
inputFile.open("Bib.txt");
inputFile >> easyBib;
cout << easyBib << endl;
break;
case 3:
break;
/*case 4:
break;*/
case 4:
cout << "Thank you for playing!" << endl;
return(0);
default:
cout << "Sorry, Invalid Choice!\n";
return(0);
}
return(0);
}
getQuestion.h:
#ifndef getQuestion
#define getQuestion
int getQuestion () {
ifstream Question;
ifstream Linker; //Linker for 2 flies
ifstream Answer;
string A;
string L; //Linker for 2 flies
string Q;
int line;
Question.open("Question.txt");
Question >> Q;
Answer.open("Answer.txt");
Answer >> A;
Linker.open("Linker.txt");
Linker >> L;
getline(Question,line);
number_of_lines++;
#endif
コンパイラエラー:
Build Social Studies of project Social Studies with configuration Debug
CompileC "build/Social Studies.build/Debug/Social Studies.build/Objects-normal/x86/main.o" main.cpp normal x86_64 c++ com.apple.compilers.gcc.4_2
cd "/Users/student/Desktop/Social Studies"
setenv LANG en_US.US-ASCII
/Developer/usr/bin/gcc-4.2 -x c++ -arch x86_64 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -isysroot /Developer/SDKs/MacOSX10.6.sdk -mfix-and-continue -fvisibility-inlines-hidden -mmacosx-version-min=10.6 -gdwarf-2 -iquote "/Users/student/Desktop/Social Studies/build/Social Studies.build/Debug/Social Studies.build/Social Studies-generated-files.hmap" "-I/Users/student/Desktop/Social Studies/build/Social Studies.build/Debug/Social Studies.build/Social Studies-own-target-headers.hmap" "-I/Users/student/Desktop/Social Studies/build/Social Studies.build/Debug/Social Studies.build/Social Studies-all-target-headers.hmap" -iquote "/Users/student/Desktop/Social Studies/build/Social Studies.build/Debug/Social Studies.build/Social Studies-project-headers.hmap" "-F/Users/student/Desktop/Social Studies/build/Debug" "-I/Users/student/Desktop/Social Studies/build/Debug/include" "-I/Users/student/Desktop/Social Studies/build/Social Studies.build/Debug/Social Studies.build/DerivedSources/x86_64" "-I/Users/student/Desktop/Social Studies/build/Social Studies.build/Debug/Social Studies.build/DerivedSources" -c "/Users/student/Desktop/Social Studies/main.cpp" -o "/Users/student/Desktop/Social Studies/build/Social Studies.build/Debug/Social Studies.build/Objects-normal/x86_64/main.o"
In file included from /Users/student/Desktop/Social Studies/main.cpp:8:
/Users/student/Desktop/Social Studies/getQuestion.h:4: error: expected unqualified-id before 'int'
/Users/student/Desktop/Social Studies/getQuestion.h:4: error: expected `)' before 'int'
ありがとう。また、意味をなさないでください、私はプログラミングに不慣れです!私はMacOSXv。10.6.8とXCode3.2.6を使用しています。誰かが私に何かをアップグレードするように頼む前に、私は管理者ではありません(これは学校のラップトップです)
編集:みんなの助けをありがとう!コードに他の問題がありますか(パフォーマンスに関連していますか?)