c++ change function's variable argument

后端 未结 2 1966
小鲜肉
小鲜肉 2020-12-07 03:59

i want to change my variable passed as argument to this function:

bool verifyStudent(string id, string name, int grade, int points, string type) {
if(!verify         


        
2条回答
  •  醉话见心
    2020-12-07 04:00

    Quote:

    Therefore, C++ has two parameter passing mechanisms, call by value (as in Java) and call by reference. When a parameter is passed by reference, the function can modify the original. Call by reference is indcated by an & behind the parameter type.

    Here is a typical function that takes advantage of call by reference [...]

    void swap(int& a, int& b) { [...] }

    More here -> A3.5. Functions

提交回复
热议问题