// 이름 충돌을 막기 위한 도구.
// 이름 충돌의 가능성이 조금 줄어든다.
// 완전히 막을 수는 없다.
namespace one
{
void foo() { cout << "one::foo" << endl; }
}
namespace two
{
int n=10;
void foo() { cout << "two::foo" << endl; }
void goo() { cout << "one::goo" << endl; }
}
void main()
{
using namespace one; // one 안의 모든것을 "::" 없이 쓸 수 있다.
using two::goo; // two 안의 goo만 "::"없이 쓸 수 있다.
foo();
two::foo();
goo();
two::n=20;
}
// 이름 충돌의 가능성이 조금 줄어든다.
// 완전히 막을 수는 없다.
namespace one
{
void foo() { cout << "one::foo" << endl; }
}
namespace two
{
int n=10;
void foo() { cout << "two::foo" << endl; }
void goo() { cout << "one::goo" << endl; }
}
void main()
{
using namespace one; // one 안의 모든것을 "::" 없이 쓸 수 있다.
using two::goo; // two 안의 goo만 "::"없이 쓸 수 있다.
foo();
two::foo();
goo();
two::n=20;
}
'Programming > C++' 카테고리의 다른 글
| Call By Reference (0) | 2010.07.12 |
|---|---|
| Reference (0) | 2010.07.12 |
| * Inline Function (0) | 2009.11.20 |
| * Overloading 된 함수 찾는 순서 (0) | 2009.11.19 |
| * Function Overloding (0) | 2009.11.19 |