c ++改变函数的变量参数

fre*_*2ak 2 c++ variables arguments function

我想将我作为参数传递的变量更改为此函数:

bool verifyStudent(string id, string name, int grade, int points, string type) {
if(!verifyId(id)){
    cerr << "Please enter 8 charactes id! format: YYMMDDCC\n";
    cin >> id;
    return false;
} else
if(!verifyName(name)){
    cerr << "Please enter name to 35 characters!\n";
    cin >> name;
    return false;
} else
if(!verifyGrade(grade)){
    cerr << "Please enter class between 8 and 12!\n";
    cin >> grade;
    return false;
} else
if(!verifyPoints(points)){
    cerr << "Please enter points between 0 and 300!\n";
    cin >> points;
    return false;
} else
if(!verifyType(type)){
    cerr << "Please enter 1 charater type! format: R,r - regional, D,d - district, N,n - national, I,i - international\n";
    cin >> type;
    return false;
} else {
    return true;
}
Run Code Online (Sandbox Code Playgroud)

}

我应该如何访问给定变量并在未被其他函数验证时更改它?

这是我调用函数的方式:

verifyStudent(iId, iName, iGrade, iPoints, iType);
Run Code Online (Sandbox Code Playgroud)

K-b*_*llo 8

要更改参数,您必须参考:

bool verifyStudent(string& id, string& name, int& grade, int& points, string& type) 
Run Code Online (Sandbox Code Playgroud)

虽然我会说这个函数不像verifyAndCorrectStudentIfNeeded那样验证学生.