gpt4 book ai didi

c++ - 为什么我没有收到枚举比较不匹配的警告?

转载 作者:太空宇宙 更新时间:2023-11-04 13:08:50 25 4
gpt4 key购买 nike

<分区>

考虑这段代码:

typedef enum Type1
{
val11,
val12
} Type1;

typedef enum Type2
{
val21,
val22
} Type2;

Type1 type1 = val11;
if ( type1 == val22 )
std::cout << "foo";

Visual Studio 2015 不会发出任何警告(即使使用/Wall)。但是 type1val22 不是同一类型。这是正常现象还是 Visual Studio 错误?

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