[haXe] overloading parent with different type

cornel tcornel at gmail.com
Fri Apr 7 22:17:57 CEST 2006


> this seems weird to me, i know you cant overload normal functions in C++ based
> solely on return types, does this compile?

compiles happily (vc++ 2005)
it wont compile if you have something like

class A{
public:
	int f(){return 0;}
	std::string f(){return "lol";}
};

err: 'std::string A::f(void)' : overloaded function differs only by
return type from 'int A::f(void)'

> and what happens if i dont use the
> return type on a call to f() on an instance of B ?
>
> B instance;
> instance.f();

it returns 'hi', as expected

> 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();

it returns 0



More information about the Haxe mailing list