Teaching C++ Badly: Introduce Constructors and Destructors at the Same Time

For years, I used to teach constructors, destructors, copy constructors, and copy assignment at the same time — and very early in the curriculum. My reasoning was straightforward: These four special member functions interact with each other in ways that often cause them to be used together, so why not cover them together? I originally intended that question to be rhetorical; it took me years to realize that it really had an answer.


May 12, 2011
URL:http://www.drdobbs.com/cpp/teaching-c-badly-introduce-constructors/229500116

Terms of Service | Privacy Statement | Copyright © 2024 UBM Tech, All rights reserved.