mardi 29 janvier 2019

Function not declare in the scope c++ error [duplicate]

This question already has an answer here:

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