FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Override
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Override
Posted: Wed Oct 18, 2017 06:19 PM

can I add a method on a class with Override comand ?
I Know Override only to change a method with a function

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: Override
Posted: Wed Oct 18, 2017 09:45 PM

Silvio,
EXTEND CLASS
Regards,
Otto

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Override
Posted: Thu Oct 19, 2017 08:49 AM

include "c:\harbour\contrib\xhb\xhbcls.ch"

...

EXTEND CLASS QSciScintilla WITH DATA cFileName

EXTEND CLASS QSciScintilla WITH MESSAGE GetLineCount INLINE ;
::Lines()

EXTEND CLASS QSciScintilla WITH MESSAGE GotoLine( nLine ) INLINE ;
::Send( SCI_GOTOLINE, nLine - 1, 0 )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Override
Posted: Thu Oct 19, 2017 08:50 AM

I wish add a method into a fwh class from my app

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: Override
Posted: Thu Oct 19, 2017 03:31 PM

Dear Antonio,

is there much difference between inheriting and extending the inherited class to extend a class.

Best regards,
Otto

Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Override
Posted: Thu Oct 19, 2017 05:08 PM
Otto wrote:is there much difference between inheriting and extending the inherited class to extend a class.


Yes. With EXTEND you are not creating a new class but you are extending an existing class. So inheritance is not involved here.

EMG
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: Override
Posted: Thu Oct 19, 2017 05:35 PM

Hello Enrico,
thank you. I understand.

My question was not very clear.
For me sometimes it seems easier to inherit from a class than to extend.
Is there a performance disadvantage. This is what I wanted to know.

In all my FIVEWIN/Harbour documents I did not find any explanations of “class extend”.
I myself use it in some cases.
I thought maybe inheriting is easier to handle for a non experienced OOB programmer.
Best regards,
Otto

Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Override
Posted: Thu Oct 19, 2017 05:50 PM

From the perspective of OOP, you should use inheritance without any doubts. But pragmatically, sometimes it is easier to extend an existing class because you don't have to change all the places where you are using it.

EMG

Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Override
Posted: Thu Oct 19, 2017 06:20 PM

Enrico, have you checked the difference in size of the EXE using "inheritance" and using "Extend" of a class?

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: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Override
Posted: Thu Oct 19, 2017 08:00 PM

No, sorry. But I would never use EXTEND so extensively. EXTEND is absolutely not a replacement for inheritance.

EMG

Continue the discussion