In object-oriented programming, a constructor is a special method that is called when an object is created from a class. The purpose of a constructor is to initialize the object's data members and perform any other setup that is required before the object can be used.