I have the following code:
#include <iostream>
#include <string>
using namespace std;
void foo(string input){
}
int main(){
string x, y;
cin >> x;
cin >> y;
foo(x + y);
return 0;
}
Will foo parameters be copied at runtime? In other words, x and y will be concatenated, then copied, and then transferred to foo? or will they be concatenated and transferred to foo without being copied to go to foo?
Is there any way to check this? I'm not sure what to look for, so links are welcome if a similar question already exists.
source
share