C3867 : '_com_error::Description': non-standard syntax; use '&' to create a pointer to member

C3867 : '_com_error::Description': non-standard syntax; use '&' to create a pointer to member

我想在连接到数据库时捕获异常,我正在使用 try catch,我使用指针,但无论如何它都会给我这样的错误。 C3867 '_com_error::Description': non-standard syntax; use '&' to create a pointer to member。 e.Description 上也没有红线,它只是在错误列表中给我这个信息。 什么是解决方案?提前谢谢你。

try
{

}
catch (_com_error &e)
{
    printf(e.Description);
}

_com_error::说明是一个函数。

您需要使用 ():

try 
{
}
catch (_com_error &e)
{
    printf(e.Description());
}

旁注:Description() returns a _bstr_t,它可能不适用于 printf()...