本文整理汇总了C++中ExpressionNode::getVariable方法的典型用法代码示例。如果您正苦于以下问题:C++ ExpressionNode::getVariable方法的具体用法?C++ ExpressionNode::getVariable怎么用?C++ ExpressionNode::getVariable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExpressionNode
的用法示例。
在下文中一共展示了ExpressionNode::getVariable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operation
ExpressionNode::ExpressionNode(const ExpressionNode & other): //copy constructor
type(other.getType()), operation(other.getOperation()), activechildren(other.getOperation()->getArity()),
right(0), firstChild(0), variable(other.getVariable()), value(other.getValue())
{
setRight(other.getRight());
setFirstChild(other.getFirstChild()); // automatically also sets other children
}
示例2: replace
void ExpressionNode::replace(const ExpressionNode &newNode)
{
std::clog << "...<replacing> " << *this << " with " << newNode << std::endl;
//ExpressionNode *curOld;
//ExpressionNode *curNew;
setType(newNode.getType());
setOperation(newNode.getOperation());
// setRight(newNode.getRight());
setFirstChild(newNode.getFirstChild()); // automatically also sets other children
//curOld = firstChild;
//curNew = newNode.getFirstChild();
//while (curNew != 0)
//{
//curOld->setRight(curNew->getRight());
//curOld = curOld->getRight();
//curNew = curNew->getRight();
//}
setVariable(newNode.getVariable());
setValue(newNode.getValue());
std::clog << "...</replacing>" << std::endl;
}
示例3: isCompatible
bool Multiplication::isCompatible(const ExpressionNode& left, const ExpressionNode& right)
{
if (left.getType() == NUMBER && right.getType() == NUMBER)
{
return true;
}
else if (left.getType() == VARIABLE && right.getType() == VARIABLE)
{
if (left.getVariable() == right.getVariable())
{
return true;
}
}
else if (left.getType() == OPERATION)
{
if (left.getOperation() == &ADDITION || left.getOperation() == &SUM)
{
return true;
}
else if (left.getOperation() == &MULTIPLICATION || left.getOperation() == &PRODUCT)
{
return true;
}
}
else if (right.getType() == OPERATION)
{
if (right.getOperation() == &ADDITION || right.getOperation() == &SUM)
{
return true;
}
else if (right.getOperation() == &MULTIPLICATION || right.getOperation() == &PRODUCT)
{
return true;
}
}
return false;
}
示例4:
bool ExpressionNode::operator== (const ExpressionNode& other) const
{
ExpressionNode *selfptr;
ExpressionNode *otherptr;
if (getType() == other.getType() &&
getOperation() == other.getOperation() &&
getVariable() == other.getVariable() &&
getValue() == other.getValue() )
{
selfptr = firstChild;
otherptr = other.getFirstChild();
while (selfptr != 0 && otherptr != 0)
{
if (*selfptr == *otherptr)
{
selfptr = selfptr->getRight();
otherptr = otherptr->getRight();
}
else
{
return false;
}
}
if (selfptr == 0 && otherptr == 0)
{
return true;
}
else
{
assert(selfptr != otherptr);
return false;
}
}
else
{
return false;
}
}