Skip to content
  • Mike @Mikeichhalt ·

    is it correct that we dont need :: before qHash in line 6 because we use enum class and not just enum? Line 6 would be:

    return qHash(static_cast<...
  • Author Owner

    is it correct that we dont need :: before qHash in line 6

    No.

    Without ::, the compiler will not be able to find the correct qHash function. Unary scope operator:: say that we need to call a function from the global scope, but not from the current namespace.

    According to the c++03 standard 3.4.3.4:

    A name prefixed by the unary scope operator :: (5.1) is looked up in global scope, in the translation unit where it is used. The name shall be declared in global namespace scope or shall be a name whose declaration is visible in global scope because of a using-directive (3.4.3.2). The use of :: allows a global name to be referred to even if its identifier has been hidden (3.3.7).

    Edited by frostasm
  • Mike @Mikeichhalt ·

    ah ok. it only works without it because the call is in global.

    thanks

0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment