My question is simple. When do we need to have a default constructor? Please refer to the code below:
class Shape
{
int k;
public:
Shape(int n) : k
The compiler will define a default ctor if and only if you don't explicitly declare any ctors.
Note that what's important is declaring the constructor, not necessarily defining it. It's fairly common, for example, to declare a private ctor, and never define it, to prevent the compiler from implicitly defining any others.
Edit: Also note that C++11 has an =default syntax for dealing with situations like yours.