Skip to content

Possibility to override parent class variables with child class variables in super constructor #952

Open
@TheSkullbot

Description

@TheSkullbot

Is your feature request related to a problem? Please describe.
Unless I'm doing it wrong, you can't override parent (abstract) class member variable from the child class

Describe the solution you'd like
Being able to override (abstract) parent member variables with child class member variables of the same name, maybe with an "override" keyword
This would enable things like this :

public abstract class CustomUnitDefinition extends UnitDefinition
  string name = "Default Unit Name"
  construct( int unitId, int origID )
    super( unitId, origID )
    setName( name ) // Since you can't instanciate CustomUnitDefinition , setName should be called with the value of MyUnit.name

public class MyUnit extends CustomUnitDefinition 
  string name = "Child Unit Name" // Should override CustomUnitDefinition .name
  construct( int unitId, int origID )
    super( unitId, origID )
    // setName( "Child Unit Name" ) gets called from parent CustomUnitDefinition construct()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions