java和C ++之间的枚举的区别? [英] Difference of Enum between java and C++?
本文介绍了java和C ++之间的枚举的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好
我正在学习java中的枚举我喜欢知道在Java和C ++中Enum的主要区别是什么。
感谢
Hi I am learning Enums in java I like to know what are the major differences of Enum in java and C++. Thanks
推荐答案
在C ++中,枚举只是一组命名的,在Java中,枚举更像是类的命名实例。您可以自定义枚举中可用的成员。
In C++, an enumeration is just a set of named, integral constants. In Java, an enumeration is more like a named instance of a class. You have the ability to customize the members available on the enumeration.
此外,C ++会将枚举值隐式转换为其整数等价值,而转换必须在Java中显式。
Also, C++ will implicitly convert enum values to their integral equivalent, whereas the conversion must be explicit in Java.
有关维基百科的更多信息。
这篇关于java和C ++之间的枚举的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文