Analysis of shadows a parameter exception in C + +

string test1(string &str1){

   

string str1=”hello1″;

    return str1;

}

As shown in the above code, the exception of declaration of ‘STD:: string STR1’ shadows a parameter will be reported when compiling. The reason for the exception is the naming conflict between & amp; STR1 and STR1.

Read More: