www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - C++ const to D2 const

reply BLS <nanali nospam-wanadoo.fr> writes:
Sorry about the ignorance, but I am not a C++ programmer.
C++ / WIN API prog.
HINSTANCE GetResourceHandle() const { return (m_hResource ? 
m_hResource:m_hInstance); }

D2
invariant HINSTANCE GetResourceHandle()

Just guessing, can you confirm ?

...and by the way a very confusing C++ language construct.
RECT r = {0};

Does it mean : Set all members to 0 ? How to port this stuff into D ...
Thanks in advance.
Bjoern
Dec 23 2007
parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
BLS wrote:
 Sorry about the ignorance, but I am not a C++ programmer.
 C++ / WIN API prog.
 HINSTANCE GetResourceHandle() const { return (m_hResource ? 
 m_hResource:m_hInstance); }

 D2
 invariant HINSTANCE GetResourceHandle()
 
 Just guessing, can you confirm ?
 

No idea there.
 ...and by the way a very confusing C++ language construct.
 RECT r = {0};
 
 Does it mean : Set all members to 0 ? How to port this stuff into D ...

Yes it does. In D you have to specify all the members. RECT should have 4, so RECT r = {0,0,0,0}; should do it. --bb
Dec 23 2007
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Bill Baxter" <dnewsgroup billbaxter.com> wrote in message 
news:fkm8vn$2p75$1 digitalmars.com...

 Yes it does.  In D you have to specify all the members.  RECT should have 
 4, so
    RECT r = {0,0,0,0};
 should do it.

...except that if this isn't a static struct declaration, you have to write: RECT r = RECT(0, 0, 0, 0); :P
Dec 23 2007