相关疑难解决方法(0)

为什么我的登录名为std名称空间?

在下面的代码中,我定义了一个简单的log函数.在main我尽量称呼它; 我打电话std::log.然而,我自己log被称为; 我看到"日志!" 在屏幕上.有谁知道为什么?我使用G ++ 4.7和clang ++ 3.2.

#include <iostream>
#include <cmath>

double log(const double x) { std::cout << "log!\n"; return x; }

int main(int argc, char *argv[])
{
  std::log(3.14);
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ overloading namespaces

67
推荐指数
4
解决办法
2227
查看次数

标签 统计

c++ ×1

namespaces ×1

overloading ×1