C++ cast to D cast Part 2
Bill Baxter
dnewsgroup at billbaxter.com
Sat Sep 22 04:26:02 PDT 2007
BLS wrote:
> Hi Bill.
> Just something Regan and I allready have discussed ... but we are not
> sure about .
>
> C++
> CWin* pActive=
> reinterpret_cast<CWin*>((HWND)::GetWindowLong(msg.hwnd,GWL_USERDATA));
>
> D
> CWin pActive = cast(CWin) cast(HWND)GetWindowLong(msg.hwnd,GWL_USERDATA);
>
> where CWin is a class.
> The problem here is that pActive in D is a reference.
> Bjoern
>
The problem I see is that cast for classes in D is like dynamic_cast<>
in C++. It will return null if the typeinfo system doesn't think HWND
is a base class of CWin.
Maybe there's some way to disable that, like by casting to void* first?
Or maybe it's smarter than I'm thinking.
--bb
More information about the Digitalmars-d-learn
mailing list