gpt4 book ai didi

c++ - static_cast 对 getInt() 函数有意义吗?

转载 作者:搜寻专家 更新时间:2023-10-31 00:30:02 25 4
gpt4 key购买 nike

<分区>

这个统计数据是否有意义对于这个明确的案例

QSqlQuery q;
enum MyEnumType;
obj.setMyEnumType(static_cast<MyEnumType>(q.value(2).toInt()));

还是针对源类型不确定 int 的情况进行静态转换?

设置函数为

 void setMyEnumType(MyEnumTypetype type) { m_type = type; }

简单转换的优势是什么?

obj.setMyEnumType((MyEnumType)q.value(2).toInt());

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