일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- box-sizing
- 강화학습
- 수학
- 통신사할인
- c
- REM
- stl
- react
- 포토샵
- Prefix Sums
- float
- grid
- 확률
- transform
- 백준
- 소수
- Gap
- SK바이오사이언스
- 반응형 웹
- 상태
- 알고리즘
- spring
- 미디어 쿼리
- c++
- Photoshop
- Javascript
- skt membership
- pandas
- Codility
- CSS
Archives
- Today
- Total
sliver__
[Mastering C++ Programming] - Nested namespace 본문
728x90
- 기존 namespace 선언은 아래와 같다. (-std=c++17 이전)
namespace A
{
namespace B
{
namespace C
{
int x;
}
}
};
int main(void)
{
A::B::C::x = 100;
cout << A::B::C::x << endl;
}
- -std=c++17 버전에서는 아래와 같이 선언할 수 있다.
namespace A::B::C{
int x;
}
int main(void)
{
A::B::C::x = 100;
cout << A::B::C::x << endl;
}
- namespace 선언이 간편해졌다.
- -std=c++17 옵션을 지정안하고 빌드하면 아래와 같은 에러가 나온다.
- 하지만 빌드는 됀다.
Namespace.cpp:4:12: warning: nested namespace definition is a C++17 extension; define each namespace separately [-Wc++17-extensions]
namespace A::B::C::D::X{
^~~~~~~~~~~~
{ namespace B { namespace C { namespace D { namespace X
728x90
'CS > C++' 카테고리의 다른 글
[Mastering C++ Programming] - static_assert (0) | 2022.12.03 |
---|---|
[Mastering C++ Programming] - type auto deduction 기능 (0) | 2022.12.03 |
[Mastering C++ Programming] - Key features in C++17 (0) | 2022.12.03 |
[Mastering C++ Programming] - Deprecated / Removed feature in C++17 (0) | 2022.12.03 |
[C++] Pointer 와 Reference (0) | 2022.11.17 |
Comments