In Below code d = a; doesn't calls copy constructor.
How a is copied to d ? or In what cases we have to Overload the = operator ?
#include<iostream>
using namespace std;
class code{    
    int id;
    public:    
    code(){}//default constructor
    code(int a){
            id=a;
    }
    code(code & x){//copy constructor
        id=x.id;
    }
    void display(){
        cout<<id;
    }
};
int main(){
    code a(100);
    code b(a);//copy constructor is called
    code c=a;//copy constructor is called again
    code d;
    c=a;//copy constructor is not called this time
    std::cout << "\n id of A: ";
    a.display();
    cout << "\n id of B: ";
    b.display();
    cout << "\n id of C: ";
    c.display();
    cout << "\n id of D: ";
    d.display();
    return 0;
}
how can I effectively implement copy constructor ?
 
     
     
     
     
    