constructors necessity | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

constructors necessity

Almost in all `OOP` languages we have constructors so: 1.whats is the main necessity of constructor and may it be removed from OOP in future languages? 2.Is there any object programming language does not need to constructor?

3rd Aug 2017, 10:25 AM
Amin Ghasemi
Amin Ghasemi - avatar
2 Answers
+ 5
Why would you want to remove constructors? How else are you going to initialise your class members?
3rd Aug 2017, 11:12 AM
Hatsy Rei
Hatsy Rei - avatar
+ 1
Constructors are called when you create an object of a class, so I doubt that they may be removed. If it happend then whole class semantics wouldn't have any point, so we would go back to C language ^^ And mentioned above C has no constructors nor classes.
3rd Aug 2017, 10:30 AM
Jakub Stasiak
Jakub Stasiak - avatar