All,
I ran into this funny thing in a different post. It was pointed out to me that you can explicitly override a constructor... which doesn't seem necessary, and I am a little surprised it even compiles. Take a look:
public class TestClass
{
public function TestClass() {}
}
public class TestClass2 extends TestClass
{
public override function TestClass2() {}
}
Explicitly calling override on the constructor might just be a no-op, as it is certainly not necessary. My question: Is there a subtlety here that I am missing? Does explicitly overriding the constructor tell the compiler something?
public class TestClass
{
public function TestClass() {}
}
public class TestClass2 extends TestClass
{
public override function TestClass2() {
super();//this makes call to the default constructor
}
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