&lpDirectDrawObject
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;
April 16, 2001 10:13 PM
It is kinda wierd. You''re passing the address of a pointer, so it''s a pointer to a pointer. ;?>
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!![](http://www.aeon-software.com/misc/notiberia.gif)
"All your women are belong to me." - Nekrophidius
![](smile.gif)
-Ironblayde
Aeon Software
![](http://www.aeon-software.com/misc/notiberia.gif)
![](http://www.aeon-software.com/misc/notiberia.gif)
"All your women are belong to me." - Nekrophidius
![](http://www.aeon-software.com/temp/resist.png)
"Your superior intellect is no match for our puny weapons!"
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement