New method overload problem

Monkey Forums/Monkey Programming/New method overload problem

Shagwana(Posted 2011) [#1]
What could I be doing wrong?
Import mojo

Class BaseClass 
  Field ParentThing:AppTest
  Method new(a:AppTest)
    ParentThing = a	
  End
  Method show_me:void() abstract     'wanted child method
End


Class ChildClass1 Extends BaseClass
  Method show_me:void()
    Print("ChildClass1")
  End 	
End 

Class ChildClass2 Extends BaseClass
  Method show_me:void()
    Print("ChildClass2")
  End 	
End 



Class AppTest Extends App
  Method OnCreate:Int()
    Local Problem:BaseClass = new ChildClass1(Self)
  End
End

Function Main:Int()
  New AppTest
End


Now it show "<32> : Error : Unable to find overload for new(AppTest)." as the error when I compile.

If I copy the new command from the BaseClass to each of the ChildClass's then it will work, but this kind of defeats the purpose of what I am trying to do.

I really only want to define the new method once, not in each of the childs.

Any ideas?


Shagwana(Posted 2011) [#2]
As always, right after I post something like this I figure it out...
  Method new(a:AppTest)
    Super.new(a)
  End

Just needed to add the above to each of the ChildClasses.


ziggy(Posted 2011) [#3]
"New" overloads do not get inherited. It's a sort of exception.