Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The namespace starts with :: in C++ [duplicate]

Tags:

c++

namespaces

Possible Duplicate:
What's the purpose of a leading “::” in a C++ method call

This gtest has the example code.

::testing::AssertionResult IsEven(int n) {
  if ((n % 2) == 0)
    return ::testing::AssertionSuccess();
  else
    return ::testing::AssertionFailure() << n << " is odd";
}

How does it work? If the namespace is testing, isn't it testing::AssertionResult is the right usage?

like image 818
prosseek Avatar asked Feb 25 '23 10:02

prosseek


1 Answers

The :: prefix refers to the global namespace, so this is like an absolute versus relative path specification.

like image 155
Keith Avatar answered Mar 06 '23 23:03

Keith