Links

Categories

Tags


« | Main | »

namespace and using

By Jewe | June 4, 2014

namespace std
{
    class Outer
    {
        class Inner
        {
            const string Hello = "Hello World!";
            string msg;
            method Inner() { msg = ""; }
            function Print(Inner i) { }
        }

        method Outer() // access member class
        {
            inner = new Inner();
            inner.msg = Inner::Hello;
            Inner::Print(inner);
        }
        Inner inner;
    }

    class No_Using
    {
        method No_Using() // access member class without 'using'
        {
            inner = new Outer::Inner();
            inner.msg = Outer::Inner::Hello;
            Outer::Inner::Print(inner);
        }
        Outer::Inner inner;
    }

    class Using
    {
        using std::Outer::Inner; // declare namespace usage
        method Using() // access member class with 'using'
        {
            inner = new Inner();
            inner.msg = Hello;
            Print(inner);
        }
        Inner inner;
    }
}

Topics: code examples | Comments Off on namespace and using

Comments are closed.