What is the difference between default constructors and parameterized type of constructors? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the difference between default constructors and parameterized type of constructors?

Taking a program as an example would be grateful?

16th Jul 2017, 4:32 AM
Sai Yerni Akhil
Sai Yerni Akhil - avatar
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. 🍕
16th Jul 2017, 4:48 AM
Manual
Manual - avatar
+ 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
16th Jul 2017, 4:43 AM
voidneo
+ 2
Here is a code that I made using a constructor with parameters edit here it is: https://code.sololearn.com/ctW11V3p29WT/?ref=app
16th Jul 2017, 4:41 AM
Manual
Manual - avatar