0

about constructor parameter

Class My_class{ private: Int k } \*If i declare a constructor with a parameter to input*\ My_class(int r){ k=r } \*Then, what if I create an object without entering the parameter*\ My_class obj

4th Aug 2017, 6:22 AM
Atix
3 Antworten
+ 2
Compile error happens. No matching call for constructor with 0 parameters
4th Aug 2017, 7:13 AM
Eligijus Silkartas
Eligijus Silkartas - avatar
0
Thank you
4th Aug 2017, 7:18 AM
Atix
0
To prevent compile error, you can either do a parameter with a default value, or add a constructor with no parameter
4th Aug 2017, 9:15 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar