gpt4 book ai didi

c++ - 与枚举的隐式转换

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:38:06 26 4
gpt4 key购买 nike

这是一个基本问题,我希望轻松地谷歌一下,但没有找到答案。

假设我有一个枚举:

enum abc { a, b, c };

支持哪些隐式转换?编译器之间是否有任何编译器扩展或不同行为?

我问的是关于到枚举的隐式转换:

enum abc test = (** which type can appear here? **);

以及从枚举的隐式转换:

(** which type can appear here? **) test2 = test;

我想知道 C 和 C++ 的答案。

最佳答案

正如引用所说:

Values of unscoped enumeration type are implicitly-convertible to integral types

Reference link

关于c++ - 与枚举的隐式转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40921141/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com