c++ - Constructor or Assignment Operator -


Can you help me in the C ++ standard definition that is called a constructor or assignment operator in this case:

  #include & lt; Iostream & gt; using namespace std; Class CTEST {Public: Cite (): M_Netest (0) {COAT & LT; & Lt; "Default Constructor" & lt; & Lt; Endl; } CEIST (Int a): M_Entest (A) {COT & LT; & Lt; "Inti Constructor" & lt; & Lt; Endl; } Cteist (Constricted and OBJ) {M_Nist = Obj.m_ntext; Cout & lt; & Lt; "Copy Constructor" & lt; & Lt; Endl; } CEEST & amp; Operator = (integer rhs) {m_nTest = rhs; Cout & lt; & Lt; "Assignment" & lt; & Lt; Endl; Return * This; } Conserved: int m_nTest; }; Int _tmain (int argc, _TCHAR * argv []) {Cteest B = 5; Return 0; }  

Or is this just a matter of compiler optimization?

What's going on here, depends a little bit on your compiler, using a built-in intricator constructor Can make temporary objects and then that can temporarily copy B This will most likely leave the copy constructor call. In no case the assignment operator will be used.


Comments