C++ : what is :: for?

前端 未结 5 977
名媛妹妹
名媛妹妹 2020-12-14 16:40

If you go to the accepted answer of this post

Could someone please elaborate on why he uses:

double temp = ::atof(num.c_str());

and

5条回答
  •  -上瘾入骨i
    2020-12-14 16:43

    :: is the scope resolution operator. Its use in this scenario, as a unary operator, is to ensure that the name (atof) is always looked up in the global scope -- this can be useful to prevent name hiding from interfering with the lookup.

提交回复
热议问题