Cast Object parameter 'byref' 
Author Message
 Cast Object parameter 'byref'

Hi,

I have a problem when objects are passed by reference (compare with VT_BYREF
in automation)

Simple sample

// this compiles but might give a object reference null exception
void blah(Object * anyvalue)
{
    // this does not always work
    Boolean myBool = *static_cast<__box Boolean *>(anyvalue);

    //??? why does this compile and work as well?
    Object * othervalue = __box(true);
    Boolean otherBool = static_cast<Boolean>(othervalue):

Quote:
}

--


Sun, 26 Jun 2005 21:57:22 GMT  
 Cast Object parameter 'byref'
Solved.
it should be
    Boolean myBool = *dynamic_cast<Boolean *>(anyvalue);


Sun, 26 Jun 2005 22:20:25 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Why can't overload type cast to base type (object)

2. array issue 'type cast warning'

3. Compiler error C2440: 'type cast'

4. error C2440: 'type cast' :

5. Wrapper classes and 'ref' parameters

6. How to pass parameters represented by '...'?

7. pCmd->Parameters->Count fails when there's no parameter

8. binary 'operator *' has too many parameters

9. warning C4100: 'x' : unreferenced formal parameter

10. 'mem_fun' : cannot convert parameter 1

11. Warning C4100: '_P' : unreferenced formal parameter

12. Still Can't Stored Procedure's Output Parameter from DLL.(+ the Result Set)

 

 
Powered by phpBB® Forum Software