Physics, asked by Bhagabandas3986, 1 year ago

Define constructor and give example

Answers

Answered by khalidrja78
1
A constructor is a special method that is used to initialize a newly created object and is called just after the memory is allocated for the object. ... If no user-defined constructor is provided for a class, compiler initializes member variables to its default values. constructor is a special type of function with no return type. ... We define a method inside the class and constructor is also defined inside a class. A constructor is called automatically when we create an object of a class. We can't call a constructor explicitly. Let us see the types of constructor.
Similar questions