Local function declaration inside namespace

后端 未结 2 1440
旧巷少年郎
旧巷少年郎 2021-01-05 01:35

In such a situation

namespace n {
    void f() {
        void another_function();
    }
}

Should the function another_function

2条回答
  •  无人及你
    2021-01-05 01:45

    C++11 3.5 (as well as C++03)

    7 When a block scope declaration of an entity with linkage is not found to refer to some other declaration, then that entity is a member of the innermost enclosing namespace. However such a declaration does not introduce the member name in its namespace scope.

    The declaration in your example declares n::another_function.

提交回复
热议问题