+ 1
What is the difference between default constructors and parameterized type of constructors?
Taking a program as an example would be grateful?
3 Answers
+ 7
As @noname said, you can add values, arguements, parameters to a constructor.
say if you have a pizza class and you want to add cheese to each pizza created.
You set the function to add to be triggered by the constructor, so every pizza created has cheese.
đ
+ 4
Constructors give objects initial values to its attributes, which are zero, empty strings and false by default. If a constructor is patametized you can choose initial values when you instance / initialize / create the object
+ 2
Here is a code that I made using a constructor with parameters
edit here it is:
https://code.sololearn.com/ctW11V3p29WT/?ref=app