if (counter ) 与 If (counter !=0) 相同吗?

if (counter ) is the same as If (counter !=0)?

我正在学习c++,我想知道语句是否正确 “如果(计数器)”与“如果(计数器!=0)”相同

如果counter是built-in原始类型(intdouble、指针),是的,意思是一样的。如果它不是原始类型,它们可能意味着完全不同的东西(无论 operator bool 和定义用于与可从 int 隐式转换的东西进行比较的比较器发生在 return 上)。