Click here to Skip to main content
15,915,019 members

Comments by lrinish (Top 3 by date)

lrinish 28-Sep-13 22:48pm View    
I guess I should have tried this before I responded. It just made sense so I thought it would solve the issue but device is still NULL after the caller returns. Like mentioned I have no trouble returning "WebCamDevice*" but when I pass it back it gets lost. I tried two more methods passing by pointer (no pointer to pointer) and by reference. Passing by pointer ends with a NULL value and passing by reference returns with an uninitialized object. Its almost acting like its passing the parameter by value.
lrinish 28-Sep-13 22:10pm View    
Deleted
Spoke to soon this is still not working. Device is getting set properly but its just not being passed back to the caller. I changed it to the code below but still no dice. I can change the code to return "device" just fine but I'm really trying to understand why this doesn't work.

<pre>
WebCamDevice* device = NULL;
deviceList->GetDevice(index, device);

//device is still NULL.


HRESULT WebCamDeviceList::GetDevice(size_t index, WebCamDevice* device) {
HRESULT hr = S_OK;
if (index < _DeviceList.size()) {
device = _DeviceList[index];
}
//device is not null at this point
return hr;
}</pre>
lrinish 28-Sep-13 19:10pm View    
Thank you pasztorpisti for your help. I made this work by returning the WebCamDevice* before I made this post but this code is not even close to finished and I will be changing the hr value.

I understand that WebCamDevice** is a bad habit. I do this more for a visual clue to myself that this parameter is an output variable and that I'm changing what WebCamDevice* is pointing at. Probably not the best practice but like I said I'm relearning this stuff.