Missing ';' after top level declarator problem

Dec 28, 2017 at 9:07pm
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;
}
Dec 28, 2017 at 9:11pm
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.

Dec 28, 2017 at 9:12pm
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 Dec 28, 2017 at 9:13pm
Dec 28, 2017 at 9:13pm
If I had to guess, the problem is before this code.
Dec 28, 2017 at 9:41pm
So, before this code there was a struct. If I typed "typedef" before struct it works, otherwise it didn't. why that?
Dec 28, 2017 at 9:53pm
We cannot comment on what we cannot see.
Dec 29, 2017 at 9:51am
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.
Topic archived. No new replies allowed.