#include <iostream>
using namespace std;
class Student
{
public :
Student() { };
Student(const Student& s) { cout << "COPY CONSTRUCTOR CALLED\n";}
};
Student f(Student u)
{
Student v(u);
Student w = v;
return w;
}
main()
{
Student x;
Student y = f(f(x));
}
According to me there should be 8 calls as each function call calls the copy constructor 4 times.
1) copying x to parameter u
2) copying u to v
3) copying v to w
4 ) returning w
Please help me. I am having lots of difficulty in understanding these concepts.