سؤال

I have a public function in a C++/CX class:

using Windows::Foundation
Collections::IVectorView<IType^>^ F(Point p);

Separately I have an enum in a purely native class:

namespace N
{
    enum E
    {
        kA, kB, kC
    };
}

I would like to create an overload of F that also accepts an E:

Collections::IVectorView<IType^>^ F(Point p, N::E e);

Of course it's an error to include a native type in the signature of a public function. Is there any way to expose this enum to my managed callers?

هل كانت مفيدة؟

المحلول

As others have pointed out, the solution to this is to declare enum E as a 'public enum class E' instead. In most cases, this can be treated (and is as efficient as) a native C++ enum, but it is also visible and published at the ABI level and is callable and usable by other WinRT callers. This will be projected into other WinRT languages appropriately (e.g. it will be seen as an enum in C#).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top