I am new to OOP.
I have read that "the constructor which takes no arguments is called the default constructor".
Is the below constructor a default constructor?
Class A
{
int a;
string b;
public A()
{
a=10;
b="Test";
}
}
Yes, it is, since it doesn't have any parameters/arguments.
An example of a non-default constructor would be:
public A(int a)
{
this.a = a;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With