本文整理汇总了C++中Expression::add方法的典型用法代码示例。如果您正苦于以下问题:C++ Expression::add方法的具体用法?C++ Expression::add怎么用?C++ Expression::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Expression
的用法示例。
在下文中一共展示了Expression::add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv) {
//Constant c('p', 3.14);
Number* pi = new Constant("pi", 3.141592654);
//cout << pi->getRep();
Number* two = new RationalNumber(2);
Number* oneHalf = new RationalNumber(1,2);
Number* poop = new Constant("poop", 3.141592654);
//cout << two->getRep() << endl;
// cout << oneHalf->getRep() << endl;
// cout << pi->getRep() << endl;
Expression* exp = new Expression(pi);
//exp->add(two);
exp->add(oneHalf);
exp->mult(two);
exp->mult(two);
exp->add(poop);
exp->add(two);
//exp->add(oneHalf);
//exp->mult(oneHalf);
/*
* Fishy stuff is going on here. Something is not working right.
*/
//exp->mult(oneHalf);
// exp->mult(pi);
//exp->mult(oneHalf);
cout << exp->getRep();
return 0;
}
示例2: clon
Expression Expression::clon() const {
Expression cloned;
for (auto const& term : termList_) {
cloned.add(*term.get());
}
return cloned;
}
示例3: add
void Eulers::add(Eulers* a) {
try {
this->getCoefficient()->add(a->getCoefficient());
}
catch (Exceptions e) {
Expression* exp = new Expression(this->getCoefficient());
exp->add(a->getCoefficient());
this->coefficient.push_back(exp);
}
}