如何使用_variant_t访问器函数? [英] How are _variant_t accessor function used?
问题描述
我正在编写一个数据库访问类,最终将返回一个_variant_t作为结果。我需要提取返回的数据。最初我打算将它转换为所需的类型,但是ITS知道它不是必要的所有我应该do是使用访问者。
请问如何使用访问者。
如果我在leasd显示一行,我会很感激代码访问变量并将评估结果分配给变量。
请在此处查看相关问题:
http://www.codeproject.com/Questions/722847/Can-the-void-pointer-returned-by-SafeArrayGetElemeI
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
推荐答案
_variant_t已定义在comutil.h中,任何人都可以看到。
http://msdn.microsoft.com/en-us/library/ew0bcz27.aspx [ ^ ]
您可能需要使用类型转换来获取适当的提取器。
_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.
_variant_t <中的提取器/ code> class只是重载的运算符,如 short
, long
, float
, double
等最终最终调用 VariantChangeType
API。
语法与类型转换相同 -
Extractors in the_variant_t
class are nothing but overloaded operators likeshort
,long
,float
,double
etc. that finally end up calling theVariantChangeType
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);
这篇关于如何使用_variant_t访问器函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!