Copy assignment operator= is not called

Viewed 193

Why overloaded operator (operator=, specifically) is not called in this case?

#include<iostream>
using namespace std;

class mc{
    public:
        mc()=default;
        mc(mc& that){cout<<1;} //simplified copy constructor
        mc& operator=(mc& that){cout<<2; return that;} // simplified copy assignment operator
        mc operator=(mc that){cout<<2; return that;}   // another simplified copy assignment operator
};

int main(){
    mc i;       //call default constructor
    mc j = i;   //Why this line calls j's copy constructor? 
                //It used "=" symbol, how come copy assignment operator (operator=) is not called? 
}
1 Answers
Related