c++ - 有什么作用? : mean in C++?

标签 c++

我找到了这段代码:

std::string(avdInfo_getSystemImagePath(m_avd)
                                ?: avdInfo_getSystemInitImagePath(m_avd))

我只找到了关于条件运算符的信息:http://www.cplusplus.com/articles/1AUq5Di1/

也就是说,?和 : 是分开的。但是,当他们在一起时,这意味着什么? avdInfo_getSystemImagePathavdInfo_getSystemInitImagePath 都返回 char*

最佳答案

这是一个 GCC extension .

x ?: y

相同
x ? x : y

除了 x 只会被评估一次。

关于c++ - 有什么作用? : mean in C++?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66198948/

相关文章:

c++ - 代码块 C++ 线程错误

c++ - 在重载的 operator new 中初始化类成员是否未定义?

c++ - C++模板中的运算符重载

c++ - OpenCV 中的 accumulateWeighted 断言失败

c++ - nlohmann JSON C++ 包含问题

C++ 模板运算符重载 std::enable_if

c++ - 有没有办法在 C++ 中将字符串文字作为引用传递

c++ - 将对 const 指针的引用从指向非 const 的指针定位

c++ - 使用 ifstream 从 C++ 文件中读取二进制无符号短整型

c++ - 从 'Complex*' 到 'Test*' [-fpermissive] 的无效转换