문제

I've recently started working the C++/CLI managed code, but I've always defined enums like so:

enum FV_MODE
{
    IDLE,DRAG,ADD_HITBOX,ADD_HURTBOX
};

Until today, when I was hit with the error message:

cannot define an unmanaged enum 'FViewer::FV_MODE' inside managed 'FViewer'
1>          use 'enum class'

As suggested in the message and on various Stack Overflow questions, changing my code to:

enum class FV_MODE
{
    IDLE,DRAG,ADD_HITBOX,ADD_HURTBOX
};

quickly fixed the problem.

However, I'm still unaware of the differences between the 2 different ways I now know to define enums. Could anybody help clarify for me? And also what makes "enum class" more suitable for managed code?

Thanks in advance,

Guy

도움이 되었습니까?

해결책

The difference between unmanaged enums and managed enums that makes managed enums more becoming for managed code is that managed enums are managed code and unmanaged enums are unmanaged code. Managed enums can be communicated by the managed code metadata. Unmanaged enums cannot, meaning they may not manifest as part of a managed class.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top