why copy constructor is call when we pass an object as an argument by value to a method
i am new to C++ programming, when i am doing some C++ programs i have got a doubt that is why copy constructor is called when i pass an object as argument by value to a function. please see my below code in that i am passing a object of class as an argument by value to a function display() but it calling copy constructor and then control is hitting the display() function but i am understanding why it so please help. #include "stdafx.h" #include <iostream> using namespace std; class ClassA { private: int a, b; public: ClassA() { a = 10, b = 20; } ClassA(ClassA &obj) { cout << "copy constructor