This is really a discussion on OOP but in short this is why that you’re seeing that error without the use of super, note I’m coming from a Java world and using C# mainly due to Unity3D, but i’m pretty sure this is accurate enough in a UnityScript context as well.
When you define a class, say BaseClass in your example, you do one of two things regarding constructors:
A. You define NO constructors - in this case, UnityScript will “assume” a default constructor, one with no arguments.
B. You define ONE OR MORE constructors - when you do this, you’re now saying “this is the only means by which this class can be created”, and UnityScript will not create a default no argument constructor for you, this is left up to you to do if you want it since you have specified one or more constructors.
So if you define BaseClass with a constructor BaseClass(int), what that is saying is that the only way by which you may instantiate a BaseClass, is by providing an int (incoming). Trying to create it using a float, double, string … or no parameter at all even … is INVALID.
If you want to allow BaseClass to be created for more cases than just BaseClass(int), you’ll need to specify more constructors, so for instance, you could create a second constructor BaseClass() to ensure you have a default constructor or if you like, you could even just specify a default constructor by itself to be explicit.
Now - SubClass you created to “be a” type of BaseClass. When you specified a constructor SubClass(int), that is fine it just means SubClass requires an int to be created as per discussion above. The problem is, if BaseClass requires an int too (see your first example), then when SubClass is instantiated, it tries to in turn, first instantiate a BaseClass to build itself from (not quite but close enough for our purposes). Anyhow, so now in the code:
function SubClass(incoming: int)
{
// nothing here means it attempts to fallback on a DEFAULT NO-ARG constructor to invoke parent class
}
So since you have no code, it assumes default no-arg, and it tries to create a BaseClass. But BaseClass ONLY allows for (int) and does not have a default constructor and therefore fails.
This is why you must specify super(int) - super essentially just tells UnityScript that “hey instead of using a default no-arg constructor, use THIS constructor to build BaseClass instead!”.
Hopefully i’ve articulated that well enough - happy coding!