Specifying inherited arguments in child class constructor?

Comments

2 comments

  • Alejandro Hitti

    I second this. On my example here, you can see how you can't use constant values to pass to the parent class, which is often useful.

     

    function ParentClass(_name, _count) constructor
    {
    ...
    }


    function ChildClass(_name, _id) : ParentClass(_name, 5) constructor
    {
    ...
    }
    3
    Comment actions Permalink
  • Devon Mullane

    While having to specify the arguments again is a bit verbose, the inability to pass through default arguments kind of hobbles the idea of inheritance.  A big reason for inheriting anything is to construct a specialized version of a general case, along with reducing any extraneous typing.  It also won't let you inherit a constructor function that is nested in a struct.

    I imagine I know why that is, but if we need to hint to the compiler that something will exist to make it work, that's fine, though I also understand you can just ignore the inheritance in this case as well.

    0
    Comment actions Permalink

Please sign in to leave a comment.