c++;语法,根据此代码返回值类型。 < P> >我想知道返回值是BoL类型(1还是0)还是int类型(根据孩子的值)< P>表达式的类型子>=2 < /C> > C++中的“代码> BoOL < /代码>(Cf. int > C)。
根据c++;语法,根据此代码返回值类型。 < P> >我想知道返回值是BoL类型(1还是0)还是int类型(根据孩子的值)< P>表达式的类型子>=2 < /C> > C++中的“代码> BoOL < /代码>(Cf. int > C)。,c++,C++,根据isCutVertex的类型,可能会提升bool。如果isCutVertex是std::vector专业化,则不会发生类型转换(撇开此处使用可能完成的任何操作不谈)。表达式 if(isRoot) isCutVertex[here] = (children>=2); 推断这是有效的 isCutVertex[here] = (children>=2); 当x结果为true或false 所以你本来可以 isCutVertex[here] = x; 或 std::vector
isCutVertex
的类型,可能会提升bool
。如果isCutVertex
是std::vector
专业化,则不会发生类型转换(撇开此处使用可能完成的任何操作不谈)。表达式
if(isRoot) isCutVertex[here] = (children>=2);
推断这是有效的
isCutVertex[here] = (children>=2);
当x结果为true
或false
所以你本来可以
isCutVertex[here] = x;
或
std::vector isCutVertex2;
isCutVertex2[0]=true;
isCutVertex2[1]=假;
isCutVertex的类型是什么,因为这是这里最重要的部分?向量是type@jay如果子数大于1,则返回<代码>真< /代码>。不,C++中的三元算子是三元条件算子<代码>:<代码>。是的。三值条件运算符与if
else
块非常不同。这个网站上到处都是。看见
bool isCutVertex[10];
isCutVertex[0] = true;
isCutVertex[1] = false;
std::vector<bool> isCutVertex2;
isCutVertex2[0] = true;
isCutVertex2[1] = false;