+ 1
(C++)Can I use the same identifie for the return variable of a function and the variable in the main program where it's stored?
For example: int sum(int A, int B) { int SUM; SUM=A+B: return SUM; } main() { int N1, N2, SUM; cin >> N1; cin >> N2; SUM = sum(N1, N2); cout << "\n" << sum << "\n"; system("pause"); } I used the "SUM" variable either in the function and in the main program, is it ok?
3 Réponses
+ 11
yes