Override

Override

Postby Silvio.Falconi » Wed Oct 18, 2017 6: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6716
Joined: Thu Oct 18, 2012 7:17 pm

Re: Override

Postby Otto » Wed Oct 18, 2017 9:45 pm

Silvio,
EXTEND CLASS
Regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 5994
Joined: Fri Oct 07, 2005 7:07 pm

Re: Override

Postby Antonio Linares » Thu Oct 19, 2017 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Override

Postby Silvio.Falconi » Thu Oct 19, 2017 8: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6716
Joined: Thu Oct 18, 2012 7:17 pm

Re: Override

Postby Otto » Thu Oct 19, 2017 3:31 pm

Dear Antonio,

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

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 5994
Joined: Fri Oct 07, 2005 7:07 pm

Re: Override

Postby Enrico Maria Giordano » Thu Oct 19, 2017 5: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
User avatar
Enrico Maria Giordano
 
Posts: 8243
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Override

Postby Otto » Thu Oct 19, 2017 5: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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 5994
Joined: Fri Oct 07, 2005 7:07 pm

Re: Override

Postby Enrico Maria Giordano » Thu Oct 19, 2017 5: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
User avatar
Enrico Maria Giordano
 
Posts: 8243
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Override

Postby cnavarro » Thu Oct 19, 2017 6: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
User avatar
cnavarro
 
Posts: 6498
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Override

Postby Enrico Maria Giordano » Thu Oct 19, 2017 8:00 pm

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8243
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: GUSPRE and 9 guests