Windows 8 C++/CX命名空间

如何使用命名空间

在标准C++里面命名空间是为了防止类型的冲突,但在Windows运行时中,使用C++编程需要给所有的程序类型添加上命名空间,这是Windows运行时的一种语法规范。命名空间可以嵌套着使用。

看下面的例子:

namespace Test

{

    public ref class MyClass{};

    public delegate void MyDelegate();

 

    namespace NestedNamespace

    {

        public ref class MyClass2

        {

            event Test::MyDelegate^ Notify;

        };

    }

}

在MyClass2里面来使用Test空间下面的类型需要通过Test::来调用。

Windows运行时的命名空间

Windows运行时的API都在Windows::*命名空间里面,在windows.winmd文件里面可以到定义。这些命名空间都是为了Windows保留的,其他第三方自定义的类型不能够使用这些命名空间。

C++/CX的命名空间

命名空间

描述

default

包含了数字和char16类型。

Platform

包含了Windows运行时的一些主要的类型,如 Array<T>, String, Guid, 和Boolean。也包含了一些特别的帮助类型如Platform::Agile<T> 和Platform::Box<T>.。

Platform::Collections

包含了一些从IVector, Imap等接口中集成过来的的集合类型。这些类型在collection.h 头文件中定义,并不是在platform.winmd 里面。.

Platform::Details

包含了在编译器里面使用的类型并不公开来使用。

原文地址:https://www.cnblogs.com/linzheng/p/2603937.html