+ 1

I'm not understanding how default constructors are used. How would I go about displaying the default constructor or is it not actually something that gets displayed?

18th Jun 2016, 3:29 AM
Daniel Ikpeama
Daniel Ikpeama - avatar
4 Answers
+ 4
the default constructor is empty and takes no arguments, that's all it is. say you have a class called Dog. You could use it like this Dog d = new Dog(); d.name = "rufus"; or you could set the constructor of Dog to be public Dog(string n){ name = n; } meaning you could use like this Dog d = new Dog("rufus"); which would have the same effect
20th Jun 2016, 8:11 AM
Matheus Fernandes
Matheus Fernandes - avatar
0
if I were to run the program, would the default be a value that I would be able to see in place of my new constructor?
19th Jun 2016, 9:43 AM
Daniel Ikpeama
Daniel Ikpeama - avatar
- 1
what do you mean with display?
19th Jun 2016, 9:15 AM
Xavier Vinken
Xavier Vinken - avatar
- 2
no
30th Jun 2016, 4:43 AM
Nzoputa Okafor
Nzoputa Okafor - avatar