Override Method

Post Reply
Natter
Posts: 524
Joined: Mon May 14, 2007 9:49 am

Override Method

Post by Natter »

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 ?
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Override Method

Post by cnavarro »

I think in this case it is better to use an EXTEND CLASS and not an OVERRIDE
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
Natter
Posts: 524
Joined: Mon May 14, 2007 9:49 am

Re: Override Method

Post by Natter »

Thanks. But I think it's about the same thing
AntoninoP
Posts: 347
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy
Contact:

Re: Override Method

Post by AntoninoP »

If you extend the class, you still call the base method using super operator

Code: Select all

#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: Select all

func1 of Derived
func1 of Base
Post Reply