Home C++_Namespace
Post
Cancel

C++_Namespace

코드 그룹화.

:: (연산자) Scope resolution Operator

1
네임::함수명

1.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
namespace A
{
    void function()
    {
        int function1 = 1;
        std::cout << function1;
    }
}
namespace B
{
    void function()
    {
        int function2 = 2;
        std::cout << function2;
    }
}
int main()
{
  A::function();
  B::function();
  return 0;
}
1
12

2.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
namespace A
{
    void function()
    {
        int function1 = 1;
        std::cout << function1;
    }
}
namespace B
{
    void function()
    {
        int function2 = 2;
        std::cout << function1;
    }
}
using namespace A;
int main()
{
  function();
  return 0;
}
1
1

참고

The Cherno : C++

This post is licensed under CC BY 4.0 by the author.