我有一个复杂的 double 组 eigenvalues
,我想使用 clog
获得每个条目的自然对数。
for (int i = 0; i < n; ++i)
{
qq[i] = clog(eigenvalues[i]);
}
我已经删除了 using namespace std;
但我仍然得到 error: reference to 'clog' is ambiguous
。
我如何明确表示我想使用 complex.h
而不是 iostream
的 clog
?
最佳答案
如果不使用 using namespace std
,我无法使用 gcc 7.3 重现这一点,但通常来自 C 头文件的所有函数都驻留在全局命名空间中。因此,您应该能够通过在 clog 前加上 ::
:
for (int i = 0; i < n; ++i)
{
qq[i] = ::clog(eigenvalues[i]);
}
关于c++ - 使用clog计算复数的自然对数时,如何解决出现的歧义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54972981/