What is Default constructor ?
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
What is Default constructor ?
Default constructor: Default constructor refers to the constructor with no parameters or argument. If it has parameters ,all the parameters contains the default values. It is a type of constructor.
Constructor refers to the special member function of the class which enable object to initialize itself when created. A constructor refers to the same name as the class name.
Properties of default constructor:
- A default constructor is called whenever the object of its class is created.
- A default constructor does not return any value.
- Default constructor should be done in the public section.
- Default constructor cannot be inherited.
- If default constructor is not defined ,compiler itself create a default constructor implicitly. This constructor called as an inline public member of its class.
Syntax for declaration of default constructor:
class class-name
{
public:
//default constructor
class name()
{
}
}
Syntax to invoke the default constructor:
class name object name;
Step by step
Solved in 4 steps with 2 images