Dans main(), x vaut : 5
Dans myFunc, variable locale x : 8
Dans le bloc de myFunc, x vaut : 8
Variable x tres locale : 9
Hors du bloc, dans la fonction myFunc, x vaut : 8
De retour dsnd main, x vaut : 5
# include void myFunc(); int main() { using namespace std; int x = 5; cout << "\nDans main(), x vaut : " << x; myFunc(); cout << "\nDe retour dsnd main, x vaut : " << x; return 0; } void myFunc() { using namespace std; int x = 8; cout << "\nDans myFunc, variable locale x : " << x << endl; { cout << "\nDans le bloc de myFunc, x vaut : " << x; int x = 9; cout << "\nVariable x tres locale : " << x; } cout << "\nHors du bloc, dans la fonction myFunc, x vaut : " << x << endl; char response; cin >> response; }
g++ main.cpp -o test
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question