赋值表达式

  • 本文关键字:表达式 赋值 c++
  • 更新时间 :
  • 英文 :


将是赋值运算符(=)返回左(或右)部分的值?

QVector<function>::Iterator it;
binOp *bpl = nullptr;

bool b1 = (bpl = dynamic_cast<binOp *>(&*(it-2))) != nullptr;

所以,我有我自己的类(binOp: function),我尝试使用dynamic_cast into expression。如果我对bpl进行赋值,它是否等于bpl,就像这样?:

bpl = dynamic_cast<binOp *>(&*(it-2)));
bool b2 = bpl != nullptr;

那么b1等于b2吗?

=赋值操作符返回对左操作数的引用。所以,你的第一个例子将工作得很好,结果将等同于你的第二个例子。

最新更新