3교시
// Namespace 문법에관해서
// 1. 개념
// 프로그램을논리적인구조로구별하기위한문법
// 아울러이름충돌을막을수있다.
// 2. 함수접근방법
//    1. 완전한이름사용
//    2. using 선언(Declaration 사용)
//    3. using 지시어(Directive 사용)
namespace Audio_System
{
        void foo()
        {
               cout << "Audio" << endl;
        }
}
namespace Video_System
{
        void foo()
        {
               cout << "Video" << endl;
        }
}
void main()
{
    Audio_System::foo();
    using Audio_System::foo;
    using namespace Video_System;
    // using 지시어: namespace 에있는함수모두를이름없이접근할수있다.
    foo();
}
// 3. 인자기반탐색( 퀴니크look up )
namespace Graphics
{
        struct Rect
        {
        };
        void Draw( Rect r )
        {
        }
}
void main()
{
        Graphics::Rect r;
        Draw( r );             // 될까? 자동으로r이속한namespace를검색한다.
        // namespace 를뒤진다.(연산자지정때유용하게사용한다.)
}
// 4. namespace 별명(Alias) 과 라이브러리의선택적사용
namespace MathLibray
{
        int plus( int a, int b )
        {
               return 0;
        }
}
// 라이브러리의교체가편해진다.
namespace MathLibray_Ver2
{
        int plus( int a, int b )
        {
               return 0;
        }
}
void main()
{
        namespace Math = MathLibray_Ver2;     //별명Math로지정해준다.
        Math::plus( 1, 2 );
}
// 5. namespace 
namespace AAA
{
        void foo();
}
void AAA::foo()
{
}
// 6. namespace 는열려있다. - 되도록이름을복잡하게만들어라!!
namespace A
{
        void foo() {}
}
//다른파일에서or 같은파일에서namespace를추가하게된다.(방지하기위해서는이름!!)
namespace A
{
        void goo() {}
}
// 7. namespace std
//#include <iostream.h>       // cout, endl 이전역공간에있다.
#include <iostream>           // cout, endl 이std라는이름공간에있다.
void main()
{
        std::cout << std::endl;
}