If copy constructor is made private
then in
Case 1: No error, the compiler doesn\'t care if the copy constructor was defined in class.
Case 1: No error, the compiler doesn't care if the copy constructor was defined in class.
T a = ("Copy Initialization");
should give an error because there's no suitable constructor to convert from "const char [20]"
to "T"
Did you mean T a = std::string("Copy Initialization");
?
Does it directly optimizes the copy without being noticing that if the constructor was made private?
No it can't. Compilers usually perform syntactic and semantic analysis prior to the code optimization phase.