在c ++ / cli中创建一个命名空间? [英] create a namespace in c++/cli?
本文介绍了在c ++ / cli中创建一个命名空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在c ++ / cli中看到过许多使用 .NET Framework命名空间的例子,如下:
使用命名空间System;
using namespace System :: IO;
但我还没有看到任何创建自己的例子。所以我想知道是否有一种方式来声明/创建我自己的命名空间,因为我会在C#:
命名空间动物
感谢您的时间:)
{
public class Dog
{
public Dog(){}
}
}
解决方案相同单个命名空间的语法。嵌套为倍数,例如for First.Second.Third:
命名空间第一个
{
命名空间第二个
{
命名空间第三个
{
//您的代码
}
}
}
在C#中也是这样:
namespace First.Second.Third
{
}
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, e.g. for First.Second.Third:
namespace First { namespace Second { namespace Third { // Your code } } }
In C# the same would be:
namespace First.Second.Third { }
这篇关于在c ++ / cli中创建一个命名空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文