0

I want to create an instance of a subclass from inside a static superclass method. Here is an example:

class Base
{
    public static function createSubclassInstance()
    {
        //What do I do here?
        return new this.getSubclassType();
    }
}

class Sub extends Base
{
}

I want to create a new Sub instance by calling:

var s:Sub = Sub.createSubclassInstance();
5
  • I think you can't extend static methods. Commented Jan 29, 2011 at 22:40
  • I am a bit confused. You are creating a Sub instance, why not just instantiate it like you would normally? Commented Jan 29, 2011 at 22:43
  • sberry2A: There is other functionality that I want to wrap inside the createSubclassInstance() which is irrelevant to the question Commented Jan 29, 2011 at 22:46
  • Looks like M28 is right, can't extend static methods Commented Jan 29, 2011 at 22:48
  • I'd really, really! like to know why you are trying to do this. Commented Jan 29, 2011 at 22:57

1 Answer 1

3

static properties aren't inherited

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.