简体   繁体   English

在 c++/cli 中创建命名空间?

[英]create a namespace in c++/cli?

I have seen many examples of using .NET Framework namespaces in c++/cli like the following:我见过很多在 c++/cli 中using .NET 框架命名空间的例子,如下所示:

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#:所以我想知道是否有一种方法可以像在 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:嵌套多个,例如 First.Second.Third:

namespace First
{
namespace Second
{
namespace Third
{

    // Your code

}
}
}

In C# the same would be:在 C# 中同样是:

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
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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