How to initialize parameterised constructor as default constructor in c++? This question was asked in my exam. We were given a parametrized constructor & it worked as default constructor too.
3 Answers
When a constructor can be invoked with no arguments, it is called a default constructor.
However, a constructor that takes arguments can be turned into a default constructor when its arguments are given default values.
For example:
class String {
public:
String(const char∗ p = ""); // default constructor : empty string
// ...
}