C++Tutorial for Beginners 31 - Constructors and Destructors

Often you want subroutines to run automatically when you create an object from a class, or what an object is destroyed. These special methods are known as constructors and destructors respectively. Constructors are great for initialising your object's state and allocating any memory the object needs; destructors allow you to clean up when the object is destroyed, deallocating memory where necessary.

Click here to download source code for this tutorial.