Witam, może ktoś doradzić o co chodzi? Dopiero zaczynam z obiektówką i nie wiem skąd ten błąd
Question* quest;
int number = 0;
string fileName = "ankieta";
while (true)
{
number++;
cout << "Aby wykorzystac swoja ankiete zamien plik ankieta.txt w folderze z programem na plik o tym samym formacie";
quest = new Question(fileName, number);
if (quest->question=="")
{
cout << "\n\n\nTo bylo ostatnie pytanie";
break;
}
if (quest->question=="")
break;
}
Kod do tej klasy
class Question
{
public:
static int qA, qB, qC;
Question(string fileName, int num);
int answer();
string question;
private:
string a, b, c;
int questNumber;
};
Funckje klasy
int Question::answer()
{
int ans=0;
bool temp = false;;
cout << question << endl <<"1."<< a << endl <<"2."<< b << endl <<"3."<< c << endl;
while (temp)
{
temp = false;
cin >> ans;
if (ans == 1)
{
qA++;
}
else if (ans == 2)
{
qB++;
}
else if (ans == 3)
{
qC++;
}
else if (ans == 0)
{
}
else
{
temp = true;
cout << endl << "Zla odp" << endl;
}
}
return ans;
}
Question::Question(string fileName, int num)
{
questNumber = num;
fstream file;
file.open(fileName + ".txt", ios::in);
if (file.good() == 0)
{
cout << "Nie udało się otworzyć pliku";
}
else
{
int lineNumber = (num - 1) * 4 + 1;
int tempNum = 1;
string tempString;
while (getline(file, tempString))
{
if (tempNum == lineNumber) question = tempString;
if (tempNum == lineNumber+1) a = tempString;
if (tempNum == lineNumber+2) b = tempString;
if (tempNum == lineNumber+3) c = tempString;
tempNum++;
}
}
}
\A błąd
Nierozpoznawalny symbol zewn