What is the difference between class _ type x (); and class _ type x; in c++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the difference between class _ type x (); and class _ type x; in c++

29th Jan 2017, 9:58 AM
gaurav kulkarni
gaurav kulkarni - avatar
2 Answers
+ 2
thanks@Michael Srczepanski
20th Feb 2017, 2:08 PM
gaurav kulkarni
gaurav kulkarni - avatar
+ 1
the first one should call the default constructor. and the second one creates am object, which calls the default constructor :/ if you are not going to overload a constructor amd assign values at the time you create the object, just use class dt x; otherwise use the parameter list. class dt x (1,2,3); jope this helps :D
20th Feb 2017, 2:06 PM
Michael Szczepanski
Michael Szczepanski - avatar