This question already has an answer here:
- Why can't a function go after Main 9 answers
 
I have a code block which throw error.
Here it is
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int x = 0;
    mysterious (x, x);//getting error in this line
    cout << x << endl;
    return 0;  
}
void mysterious(int i, int &k) {
     i = 1;
     k = 2;
} 
error: In function 'int main()': error: 'mysterious' was not declared in this scope
What is the reason behind this error. Is there any syntactical flaw?
Aucun commentaire:
Enregistrer un commentaire