0

If l use two constractor with different type like string and int but both have only one variable this give error or not?

3rd Jul 2017, 1:48 AM
esraa ragab
3 Antworten
+ 8
You might want to give a sample code / more info to better illustrate a model of the problem. Is this C++?
3rd Jul 2017, 2:14 AM
Hatsy Rei
Hatsy Rei - avatar
+ 2
You can read this for more information: https://www.csee.umbc.edu/~chang/cs202/Lectures/modules/m04-overload/slides.php?print Constructors are functions, so they follow the same rules. The rules applied for C/C++ and Java, maybe C# as well.
3rd Jul 2017, 2:56 AM
Bàng Tứ Cường
Bàng Tứ Cường - avatar
0
normally you have to define the type of the given variable, so you can create 2 Constructors IF the given types differ from each other. At least this is for Java and I guess it's applicable for C++/C# as well
3rd Jul 2017, 2:27 AM
Aisinthalor
Aisinthalor - avatar