+ 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?
4 Réponses
+ 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
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?
- 1
what do you mean with display?
- 2
no