code
#include <iostream>
using namespace std;
//네임스페이스를 선언 객체지향 프로그래밍의 생성자와 같은느낌이다.
namespace silla
{
int year = 935;
void CentralArea()
{
cout << "경상도" << endl;
}
}
namespace baekjae
{
int year = 660;
void CentralArea()
{
cout << "충청도" << endl;
}
}
//네임스페이스를 사용하겠다고 선언한다. 이때는 using키워드를 사용
using namespace silla;
using namespace baekjae;
int main()
{
cout << "신라 중심지 : ";
//::로 네임스페이안의 변수또는 함수에 접근할수 있다.
silla::CentralArea();
cout << "신라 멸망연도 : " << silla::year << endl;
cout << "백제 중심지 : ";
baekjae::CentralArea();
cout << "신라 멸망연도 : " << baekjae::year << endl;
return 0;
}