Missing ';' after top level declarator problem

At the code below there is a simple function with these errors:
gastos.cpp:13:6: error: variable has incomplete type 'void'
gastos.cpp:13:50: error: expected ';' after top level declarator

can you guys identify where the error is? Thanks!
1
2
3
4
5
6
7
8
9
10
void extrato(Produto* vetor, int qtd, string you){
    
    cout << "Extrato referente ao usuario : " << you << endl;
    float total = 0;
    for (int i = 0; i < qtd; i++){
		cout<<vetor[i].nome<<"____"<<vetor[i].preco<<endl;
		total+=vetor[i].preco;
    }
    cout << "total___" << total << endl;
}
one of 3 guesses...
either the code immediately above this function is incorrect (missing a } or a ; possibly)

or

you call the function above this code

or

you have a prototype for this function and it has a problem.

Your line numbers don't match up to your actual code. Most likely you forgot to #include something because it's complaining about an incomplete type. If it isn't too long, can you post the beginning of the file up to the function, and where you call it from?

Otherwise, make a copy of your code and delete any extraneous code that doesn't contribute towards the error.
Last edited on
If I had to guess, the problem is before this code.
So, before this code there was a struct. If I typed "typedef" before struct it works, otherwise it didn't. why that?
We cannot comment on what we cannot see.
why that?


I expect you left out a semi-colon. I am having to use psychic powers for this, though; you're bad at C++, but you're truly awful at asking questions.
Registered users can post here. Sign in or register to post.