Advertisement

&lpDirectDrawObject

Started by April 16, 2001 09:44 PM
2 comments, last by CTRL_ALT_DELETE 23 years, 9 months ago
Hwy, I just started reading a DirectX book, and am disturbed to find that the 2nd paramereter in this example, which is supposed to be the adress of the DirectDrawObject, is prefixed by an ''&.'' It was my understanding that lpDirectDrawObject was already a pointer, as signified by the "lp" prefix. And you cant apply ''&'' to pointers, can you? So what is going on. Thanks. if(FAILED(DirectDrawCreate(NULL,&lpDirectDrawObject,NULL))) return FALSE;
It is kinda wierd. You''re passing the address of a pointer, so it''s a pointer to a pointer. ;?>
Advertisement
DirectDrawCreate() allocates memory for a DirectDraw object, and then points your LPDIRECTDRAW variable to it. So for the function to be able to permanently change the value of the LPDIRECTDRAW variable, it needs an LPDIRECTDRAW* as an argument, which is a pointer to a pointer. That''s perfectly valid... think about if you were going to create a 2D array dynamically. You''d declare a variable of type int**, which is also a pointer to a pointer. It''s kind of weird but that''s the way it works.

-Ironblayde
 Aeon Software

Down with Tiberia!
"All your women are belong to me." - Nekrophidius
"Your superior intellect is no match for our puny weapons!"
Thanks IornBlayde. I hate it when I don''t understand something, and you just saved me a lot of lost sleep!

This topic is closed to new replies.

Advertisement