Click here to Skip to main content
15,923,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am writing a database access class that will eventually return a _variant_t as result.I need to extract the returned data.Initially I intended to cast it to the desired type but ITS learnt that it insn't neccessary all I ought to do is use the accessor.

Please how does one use an accessor.
Id appreciate it if I am shown at leasd a line of code that accesses a variant and assigninv the outcome of the assessing to a variable.

See associated question here:

http://www.codeproject.com/Questions/722847/Can-the-void-pointer-returned-by-SafeArrayGetElemeI
Posted
Comments
[no name] 8-Feb-14 20:13pm    
I think you mean extractor. This may help http://flylib.com/books/en/1.22.1.157/1/

_variant_t is defined in comutil.h for anyone to see.

http://msdn.microsoft.com/en-us/library/ew0bcz27.aspx[^]

You may need to use a typecast to get the appropriate extractor.
 
Share this answer
 
Extractors in the _variant_t class are nothing but overloaded operators like short, long, float, double etc. that finally end up calling the VariantChangeType API.

The syntax would be the same as a type cast -
_variant_t var(25.4);

short s = (short)var;
long l = (long)var;

OR

short s = short(var);
long l = long(var);
 
Share this answer
 
Comments
Gbenbam 11-Feb-14 2:19am    
This is so mightily clarifying.Thank you so much.Thanks a trillion times.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900