namespace
- 변수나 함수 충돌 방지
- 영역 접근 연산자 :: 사용
- ex : Aspace::test(); , Bspace::test();
#include <stdio.h>
#include <iostream>
#include <iomanip>
using namespace std;
/* using을 통해 프로그램 전체에 사용할 수 있음
* 이를 이용하여 std::cout을 cout으로 사용
*/
namespace test {
void func_1() {
// 네임스페이스 test안에 함수func_1 선언
cout << "call func_1" << endl;
}
}
void main() {
test::func_1();
//네임스페이스 test의 func_1함수 실행
}
namespace std | iostream | iomanip |
역할 | 표준 입출력 | 조정 문자 |
'C++ > 기초' 카테고리의 다른 글
[C++] 동적할당 (1) | 2023.12.18 |
---|---|
[C++] 래퍼런스(Reference) 변수, 포인터(Pointer) 변수 (0) | 2023.12.15 |
[C++] bool 자료형 (0) | 2023.12.14 |
[C++] 오버로딩, 디폴트 매개변수, 초기화 (0) | 2023.12.14 |
[C++] cin, cin.get, cout, fflush (0) | 2023.12.14 |