FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Override Method
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Override Method
Posted: Tue Nov 05, 2019 09:17 AM
In my program, I replace the class method with my function.
Override Method AAA In Class BBB With MyFnc
Sometimes as the program progresses, I need to restore the standard implementation of the method. Can this be done ?
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Override Method
Posted: Tue Nov 05, 2019 11:56 AM

I think in this case it is better to use an EXTEND CLASS and not an OVERRIDE

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Override Method
Posted: Tue Nov 05, 2019 12:10 PM

Thanks. But I think it's about the same thing

Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM
Re: Override Method
Posted: Tue Nov 05, 2019 03:23 PM
If you extend the class, you still call the base method using super operator
Code (fw): Select all Collapse
#include <hbclass.ch>

class Base
   Method Func1() INLINE QOut("func1 of Base")
endclass

class Derived INHERIT Base
   Method Func1() INLINE QOut("func1 of Derived")
endclass

proc main()
   LOCAL obj := Derived():New()
   obj:Func1()
   obj:Super:Func1()

Result:
Code (fw): Select all Collapse
func1 of Derived
func1 of Base

Continue the discussion