Page 1 of 1

Override

PostPosted: Wed Oct 18, 2017 6:19 pm
by Silvio.Falconi
can I add a method on a class with Override comand ?
I Know Override only to change a method with a function

Re: Override

PostPosted: Wed Oct 18, 2017 9:45 pm
by Otto
Silvio,
EXTEND CLASS
Regards,
Otto

Re: Override

PostPosted: Thu Oct 19, 2017 8:49 am
by Antonio Linares
#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 )

Re: Override

PostPosted: Thu Oct 19, 2017 8:50 am
by Silvio.Falconi
I wish add a method into a fwh class from my app

Re: Override

PostPosted: Thu Oct 19, 2017 3:31 pm
by Otto
Dear Antonio,

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

Best regards,
Otto

Re: Override

PostPosted: Thu Oct 19, 2017 5:08 pm
by Enrico Maria Giordano
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

Re: Override

PostPosted: Thu Oct 19, 2017 5:35 pm
by Otto
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

Re: Override

PostPosted: Thu Oct 19, 2017 5:50 pm
by Enrico Maria Giordano
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

Re: Override

PostPosted: Thu Oct 19, 2017 6:20 pm
by cnavarro
Enrico, have you checked the difference in size of the EXE using "inheritance" and using "Extend" of a class?

Re: Override

PostPosted: Thu Oct 19, 2017 8:00 pm
by Enrico Maria Giordano
No, sorry. But I would never use EXTEND so extensively. EXTEND is absolutely not a replacement for inheritance.

EMG