[haXe] overloading parent with different type
Martin Wood
flashdev at relivethefuture.com
Fri Apr 7 22:05:30 CEST 2006
cornel wrote:
> hi all
>
> Nicolas,
> Related to my older post, about qooxdoo: i wrote some code that would
> create haxe interfaces out of qooxdoo classes, and i've encountered
> the same problem: there's a lot of methods that override methods with
> the same name in the parent class. I'm not sure i understand why this
> is an error.
> For example, c++ has no problem with this code:
>
> class A{
> int f(){return 0;}
> };
>
> class B:public A{
> std::string f(){return "hi";}
> };
>
> Could you please elaborate a bit?
this seems weird to me, i know you cant overload normal functions in C++ based
solely on return types, does this compile? and what happens if i dont use the
return type on a call to f() on an instance of B ?
B instance;
instance.f();
what happens if i have a pointer to a B, but declared as type A and call f
without using the return type?
A *instance;
instance = new B;
instance->f();
just curious :)
thanks,
Martin
More information about the Haxe
mailing list