Help me with my style

Started by
12 comments, last by Nodger 20 years, 5 months ago
quote:
Why do none of the windows api functions return them then?

They return handles instead of pointers, which basically hold an id for a resource that is stored by the system and you have to use that id instead of a pointer because windows doesn't want you messing around with it (free'ing it, modifying it, etc.).


[edited by - brassfish89 on November 16, 2003 7:14:30 PM]
Advertisement
A handle is a void pointer or a pointer to a structure.

#IFDEF STRICTtypedef void* HANDLE;#define DECLARE_HANDLE(name) struct name##__{ int unused; }; typedef struct name###__ *name;#elsetypedef void* HANDLE;#define DECLARE_HANDLE(name) typedef HANDLE name#endif// and this is used inside windows header files like thisDECLARE_HANDLE(HICON);DECLARE_HANDLE(HCURSOR);DECLARE_HANDLE(HMENU);// ...etc...  


[edited by - angry on November 16, 2003 11:47:50 PM]
Pick up "Effective C++" and "More Effective C++" by Meyers, as well as "The C++ FAQs" by Cline, Lomow, and Girou.

--
Dave Mikesell Software & Consulting
I can definitely recommend that you buy Effectice C++, it may only around 250 pages but it''s definitely worth buying

This topic is closed to new replies.

Advertisement