C++ 中的 if 语句中的接口对象
Object of an interface inside if-statement in C++
你好,我有一个简短的问题。 由于我对C++不太熟悉,并且我现在正在浏览一些代码,我想知道类似于这个函数的函数中发生了什么:
#include "SomeInterface.h"
class SomeClass {
public:
...
void SomeFunction(...){
if (interface) { //What is asked here exactly?
/*do something*/
}
}
/*...*/
protected:
SomeInterface* interface;
}
由于我来自Java,我想知道if括号中问了什么。 我习惯于只有在变量为 bool 类型时才能在 if 括号中放置一个孤独的变量名称。但是由于这里是自定义界面类型,我很困惑。
提前感谢您的回答。
既然interface
是一个指针,那么
if (interface)
相当于
if (interface != nullptr)
指针可隐式转换为bool
nullptr
将false
,其他任何内容都将true
。
相关文章:
- 在C ++ ASIO中,如何为HTTP或HTTPS创建相同的套接字对象(接口/抽象问题?
- 无法使用接口类型对priority_queue中的对象进行排序<T>
- 防止通过接口删除对象
- 如何通过接口将函子分配给函数对象
- C++接口实现和子类化对象识别
- 2 个 COM 对象,并在另一个对象中使用其中一个对象的接口
- 在构造函数处将类对象强制转换为接口始终返回 NULL
- 尝试向 COM 对象添加另一个接口时出现静态强制转换错误 C2440
- C++ 中的 if 语句中的接口对象
- 我们可以在同一对象中实现多个QtRO接口吗?
- C++实现相同接口的对象/类之间的数据共享
- neak_ptr vs unique_ptr参考 - 传递接口inmand tos to其他对象
- 如何使用 word 对象模型中的C++接口在 word 中添加自定义 XML 艺术
- OOP - 存储对象和服务接口
- 如何在接口类中创建一个超类对象
- Python - 导入 c++ 模块接口 - 无法打开共享对象文件
- 如何为对象提供不同的接口(最佳)
- 如何将接口对象强制转换为特定的继承对象
- 对于range (c++11)使用虚接口对象
- 带有接口对象的c++模板