OOP in Harbour Guide

178 views
Skip to first unread message

marcos...@gmail.com

unread,
Jul 18, 2025, 10:22:04 AMJul 18
to Harbour Users

Hello

I've added a new example to the Harbour OOP manual to demonstrate how inheritance is implemented.

I've attached an image showing the structure of the inheritance hierarchies.

https://github.com/marcosjarrin/Harbour_oop_manual/tree/main/example/terminal/BioClassification

Regards

Marcos

Inheritance.jpg

alex;

unread,
Aug 7, 2025, 12:15:01 PMAug 7
to Harbour Users
Hi, Marcos.
Good work. Thank you.

May be this will be interesting:
---------------------------
#include "hbclass.ch"

PROCEDURE Main()
   LOCAL c := GET_uiClass(Test4()), o
?c
?__clsParent(c, "Test2")
?__clsParent(c, "Test3")
?__clsParent(c, "Test")

?__clsParent(c, "Test5")

o := Test4():New()
o:Test4()

?Test():Test()
Inkey(0)
RETURN

CREATE CLASS Test
   METHOD new() INLINE Self
   METHOD Test()
   ENDCLASS

METHOD Test:test()
   RETURN "qwe"

CREATE CLASS Test2 FROM Test
   METHOD new() INLINE Self
   METHOD Test2() INLINE .T.
   ENDCLASS
   
CREATE CLASS Test3 FROM Test
   METHOD new() INLINE Self
   METHOD Test3() INLINE .T.
   ENDCLASS
   
CREATE CLASS Test4 FROM Test2, Test3
   METHOD new() INLINE Self
   METHOD Test4() INLINE QOut(ProcName(1)), .T.
   ENDCLASS
 
#pragma BEGINDUMP
#include "hbvmint.h"
#include "hbapi.h"
#include "hbapiitm.h"

HB_FUNC( GET_UICLASS )
{
   PHB_ITEM pItem = hb_param( 1, HB_IT_ARRAY );
   hb_retni( pItem->item.asArray.value->uiClass );
}

#pragma ENDDUMP
---------------------------
and
DYNAMIC __clsAddFriend
DYNAMIC __clsAddMsg
DYNAMIC __clsAssocType
DYNAMIC __clsCntClasses
DYNAMIC __clsDelMsg
DYNAMIC __clsGetAncestors
DYNAMIC __clsGetProperties
DYNAMIC __clsInst
DYNAMIC __clsInstSuper
DYNAMIC __clsLock
DYNAMIC __clsLockDef
DYNAMIC __clsModMsg
DYNAMIC __clsMsgType
DYNAMIC __clsNew
DYNAMIC __clsParent
DYNAMIC __clsPreallocate
DYNAMIC __clsSyncSignal
DYNAMIC __clsSyncWait
DYNAMIC __clsUnlockDef
DYNAMIC __clsVerify
DYNAMIC __cls_CntClsData
DYNAMIC __cls_CntData
DYNAMIC __cls_CntShrData
DYNAMIC __cls_DecData
DYNAMIC __cls_IncData

HB_FUNC( __OBJSETCLASSHANDLE )

WBR alex;
пятница, 18 июля 2025 г. в 17:22:04 UTC+3, marcos...@gmail.com:
Reply all
Reply to author
Forward
0 new messages