Help with an void

Hi!

This is my first thred here!

This code is for a glossary test from swedish to english.

I have problem with (*it).engelska)! And why cant i use (*it).engelska in this code?

Many Thanks in advance!!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void prov(list<Glosor> lista)
{
        string testet;
        int santal = 0;
        int rsvar = 0;
        list<Glosor>::iterator it;
        for(it = lista.begin(); it != lista.end(); it++){
            cout << (*it).svenska << " betyder på engelska: "; // *it writes the swedish word for translate.
            getline(cin, testet); //Here you write the english word and "if" function test if it's correct.
            if(testet == (*it).engelska){
                cout << "Ratt svar!\n";
                rsvar++;
                }
            else{
            cout << "Tyvärr fel svar rätt svar är: "<< (*it).engelska) << endl; // Here i use "it" to write the correct answare if you guess wrong. But it keep telling me "error: expected ';' before ')' token"
            }
            santal++;
        }
        cout << "Du hade " << rsvar << " rätt svar av " << santal << " möjliga" << endl;
}
Last edited on
Are you saying you don't see that there's a closing parenthesis in line 15 after engelska that doesn't have a matching opening parenthesis? You need to code some more, I guess. Get more practice.

Also in the FOR loop @ line 7, use ++it instead of it++. The former doesn't create a copy of the iterator, meaning it performs faster.
You have an extra bracket. Drop the one after engelska.
Thanks BlackSheep!

i'm feeling stuupid!

Topic archived. No new replies allowed.