What are the advantages of constructor and destructor?

1 answer

Answer

1156905

2026-07-26 15:50

+ Follow

Without a copy constructor the only way to copy an object would be to instantiate a new object (or use an existing object) and then assign another object's value to it. However, it would be very odd indeed to have a copy assignment operator without a matching copy constructor. If you have one, you must have both. If you do not need to copy an object of a particular class, however, you can simply delete both the copy constructor and the copy assigment operator for that class. Any attempt to copy or copy assign would then result in a compile-time error.

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.