Can't the name of the C/C++ variable be the same as the name of the function?

Asked 2 years ago, Updated 2 years ago, 47 views

#include <iostream>
using namespace std;

int sum(int a, int b){

    return a + b;
}
int main() {
    int a , b;

    int sum = sum(5,6);

    cout << sum;


}

There's an error. Can't the variable name in the main function be the same as the function's name?

c c++ function

2022-09-20 19:49

1 Answers

Yes, the variable name and function name must not be the same.


2022-09-20 19:49

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.