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
See this for the full behaviors of C++ WRT constructors: http://en.wikipedia.org/wiki/Default_constructor
The simple answer is that if you specify a constructor, the compiler will not create a default one for you.
This rule applies to Java as well.