Answer the question
In order to leave comments, you need to log in
Copy constructor call?
struct Example
{
Example(const int &i){}
};
Example a=1; // Вызов конструктора
Example b=a; // Вызов копирующего конструктора по умолчанию
Example c=Example(1); // Но что это?
Answer the question
In order to leave comments, you need to log in
First, a constructor call to create a temporary object, then a copy constructor call from the temporary object to the one defined on the left. But the compiler can optimize to 1 call if the copy constructor is not explicitly defined.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question