Loading AI tools
개체를 구분할 수 있는 범위 위키백과, 무료 백과사전
이름공간 또는 네임스페이스(영어: namespace)는 개체를 구분할 수 있는 범위를 나타내는 말로 일반적으로 하나의 이름 공간에서는 하나의 이름이 단 하나의 개체만을 가리키게 된다.
저명한 예는 다음을 포함한다:
이름공간의 이름은 이름공간 식별자와 로컬 이름으로 구성된다. 이름공간의 이름은 일반적으로 로컬 이름에 대한 두문자로 적용된다.
ABNF 형식으로는 다음과 같이 나타낸다.
name = <namespace identifier> separator <local name>
컨텍스트 | 이름 | 이름공간 식별자 | 로컬 이름 |
---|---|---|---|
경로 | /home/user/readme.txt | /home/user (path) | readme.txt (file name) |
도메인 네임 | www.example.com | example.com (domain) | www (host name) |
C++ | std::array | std | array |
UN/LOCODE | US NYC | US (country) | NYC (locality) |
XML | xmlns:xhtml="http://www.w3.org/1999/xhtml" <xhtml:body> | http://www.w3.org/1999/xhtml | body |
펄 | $DBI::errstr | DBI | $errstr |
자바 | java.util.Date | java.util | Date |
URN (URN) | urn:nbn:fi-fe19991055 | urn:nbn (National Bibliography Numbers) | fi-fe19991055 |
핸들 시스템 | 10.1000/182 | 10 (Handle naming authority) | 1000/182 (Handle local name) |
디지털 객체 식별자 | 10.1000/182 | 10.1000 (publisher) | 182 (publication) |
MAC 주소 | 01-23-45-67-89-ab | 01-23-45 (en:organizationally unique identifier) | 67-89-ab (NIC specific) |
PCI ID | 1234 abcd | 1234 (Vendor ID) | abcd (Device ID) |
USB VID/PID | 2341 003f[5] | 2341 (Vendor ID) | 003f (Product ID) |
아래는 C++에 사용한 이름공간의 예이다.
#include <iostream>
using std::cout;
using std::endl;
namespace Box1{
int boxSide = 4;
}
namespace Box2{
int boxSide = 12;
}
int main () {
cout << Box1::boxSide << endl; //output 4
cout << Box2::boxSide << endl; //output 12
return 0;
}
Seamless Wikipedia browsing. On steroids.
Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.
Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.