C++ operator overloading to D

BLS nanali at nospam-wanadoo.fr
Sat Sep 22 11:41:40 PDT 2007


BLS schrieb:
> Hi,
> I have a small problem in translating C++ operator overloading to D
> 
> // Allready translated C++ stuff
> class CFont
> {
> public:
>   HFONT m_hFont;
> 
>   this(HFONT hFont = NULL)
>   {
>     m_hFont = hFont;
>   }
>   ~this()
>   {
>     if(m_hFont !is NULL && !DeleteObject(m_hFont))
>     m_hFont = NULL;
>   }
> 
> // TODO How to translate this C++ construct  into D
> 
>     operator HFONT() {return m_hFont;}
> 
> // That's the problem.
> 
> Sorry have  not found anything related in the docs.
> Some ideas;;; Many thanks in advance.
> Bjoern
Okay;
HFONT is declared as
#define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef 
struct name##__ *name

opcall() ?
or
HFONT.unused = m_hFont
Njet, don't think so....
Bjoern
C sucks


More information about the Digitalmars-d-learn mailing list