why I can't use the words min and max as variable names?

后端 未结 3 2045
慢半拍i
慢半拍i 2020-12-22 14:28

In this C++ program the function print_nums doesn\'t accept the vector numbers as an actual prameter when called in the switch

3条回答
  •  忘掉有多难
    2020-12-22 14:40

    The line using namespace std says that you include std namespace. By including this you are including a lot of functions and variables in this namespace.

    When you use any variables, if a variable with the same name exists in namespace std it will be tied up to it. Now by declaring another variable in your code the compiler is confused which one the coder is referring to.

    Try to use more meaningful names for your variables max_num and min_num. If you still want to use max and min, declare them in a user defined namespace and refer to them in your code.

提交回复
热议问题