#include <iostream> #include <string> using namespace std; int main() { string strA; void printtt(string strA); strA = "1"; printtt(strA); cout<<strA<<endl; system("pause"); } void printtt(string strA) { strA ="22"; }
//在自定义函数中 修改了 传入的数组参数 会引起实参的改变
22 请按任意键继续. . .
#include <iostream> #include <string> using namespace std; int main() { string strA[5]; void printtt(string strA[]); strA[0] = "1"; printtt(strA); cout<<strA[0]<<endl; system("pause"); } void printtt(string strA[]) { strA[0] ="22"; }
//而传入的不是数组的时候 在函数中修改传入参数 不会改变实参
1 请按任意键继续. . .