When we are passing object of a class to function as value the copy constructor called. it will be in continuous loop. but how its working in case of string.
For example:
#include <iostream>
#include <string>
using namespace std;
string read_string(std::string s)
{
    std::string test;
    cout<<s;
    test=s;
    return test;
}
int main() 
{
    string sir = "start";
    cout << "SIR starts out as : '" << sir << "'" << endl;
    sir = read_string(sir);
    cout << "and becomes '" << sir << "', after return from function." << endl << endl;
    return 0;
}
Here read_string(sir), we are passing sir a string object, and in the function definition we are handling as value.
Please clear the doubts.
 
     
    