What is the use of an empty comstructor in a c++ class?

I have the following doubts regarding this lecture:

  1. What does the empty constructor do?
  2. how is it different from a parameterized constructor?
  3. is it necessary to make one?
  4. how do we decide when there is a need for an empty constructor in a c++ class??

Can you clear my cofusion per these 4 points related to empty constructors in a c++ class??

Hey
An empty constructor is used to create an object/instance of the class.
Parameterised Constructor:- arguments help initialize an object when it is created. To create a parameterized constructor, simply add parameters to it the way you would to any other function. When you define the constructor’s body, use the parameters to initialize the object.

  • A constructor is automatically called when an object is created.
    No, it’s not necessary to make one-
  • If we do not specify a constructor, C++ compiler generates a default constructor(which is actually the empty constructor) for us (expects no parameters and has an empty body).

Empty constructor is always there, it’s default.

Thanks for your response ! :slight_smile:

1 Like