+ 1

Can we add two constructors in a single class?

29th Dec 2024, 11:09 AM
probesh subba
probesh subba - avatar
4 odpowiedzi
+ 6
in Python, you can only have one __init__ method. But you can define functions that can initialize your object in different ways. These works constructors essentially. also: https://www.geeksforgeeks.org/creating-multiple-constructors-python-class/ Other languages support OOP multiple constructors.
29th Dec 2024, 11:38 AM
Bob_Li
Bob_Li - avatar
+ 6
probesh subba , your post seems to be incomplete. > please add the *programming language* you are talking about in the tags.
29th Dec 2024, 2:11 PM
Lothar
Lothar - avatar
0
In C++,You can as many
30th Dec 2024, 2:03 AM
Fabien Halaby
Fabien Halaby - avatar
0
Yes , in java u can add two or more constructors but with different parameters...
30th Dec 2024, 12:46 PM
Asraf A
Asraf A - avatar