When the class with a member which is a pointer, we need implement a copy constructor for it. I have a question, if we have implemented a copy constructor, should we implement an assignment constructor too?
Best Regards,
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is not called an assign constructor but rather an assignment operator, and yes you should. The rule of thumb is: if you need to write a destructor then you should also provide a copy constructor and assignment operator (or block the compiler from generating one)