# Inheritance constructor question

**URL:** <https://forum.kirupa.com/t/inheritance-constructor-question/237190>\
**Category:** Uncategorized\
**Created:** [August 27, 2007, 11:41pm UTC](https://forum.kirupa.com/t/inheritance-constructor-question/237190 "2007-08-27T23:41:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mleep](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@mleep](https://forum.kirupa.com/u/mleep)\
**Post date:** [August 27, 2007, 11:41pm UTC](https://forum.kirupa.com/t/inheritance-constructor-question/237190/1 "2007-08-27T23:41:34Z")

</div>

what is the correct method for a constructor in a base class and a child class?

for instance i have a class called “Planet” and a subclass “Terran”  
it will run fine until i uncomment the “extends planet”

the reason i want it to extend the Planet class is that i want to have functions in all the “Planet Type” classes that are overriding the initial definition in the Planet class, much like virtual functions and abstract base classes in C++

planet code

```auto

public class Planet extends Sprite
{
        public function Planet ( planetType:uint, posX:Number, posY:Number ):void
        {
            if ( planetType == 0 )
            {
                var terran:terran_mc = new terran_mc();
                terran.x = posX;
                terran.y = posY;
                addChild ( terran );

                var blah = new Terran();
                blah.drawTerran();
            }
        }

}

```

terran code

```auto
internal class Terran //extends Planet
{
        public function drawTerran():void
        {
            trace("Drawing a terran planet");
        }
}

```
