简体   繁体   中英

create a namespace in c++/cli?

I have seen many examples of using .NET Framework namespaces in c++/cli like the following:

using namespace System;
using namespace System::IO;

But I haven't seen any examples of creating my own. So I was wondering if there is a way to declare/create my own namespace as I would in C#:

namespace Animals
   {

   public class Dog
       {
       public Dog() {}
       }
   }

Thanks for your time:)

Same syntax for single namespaces. Nest for multiples, eg for First.Second.Third:

namespace First
{
namespace Second
{
namespace Third
{

    // Your code

}
}
}

In C# the same would be:

namespace First.Second.Third
{
}

You already know how it should be done, as is demonstrated by your example

namespace NamespaceName //C++/CLI or C#
{
    //contents
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM