本文整理汇总了C++中Number::isReal方法的典型用法代码示例。如果您正苦于以下问题:C++ Number::isReal方法的具体用法?C++ Number::isReal怎么用?C++ Number::isReal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Number
的用法示例。
在下文中一共展示了Number::isReal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
Operation *p = Factory::createSubstractOperation("2-3");
p->setLeft(Factory::createIntegerNumber(2));
p->setRight(Factory::createIntegerNumber(3));
cout << p->eval(NULL)->getInteger() << endl;
GlobalContext::getInstance()->addNewLocalContest();
GlobalContext::getInstance()->addNewVariableInLastContext("n", Factory::createIntegerNumber(5));
cout << GlobalContext::getInstance()->isContaining("n") << endl;
cout << GlobalContext::getInstance()->getNumber("n")->toString() << endl;
Number *n = Factory::createNumber("2.5");
cout << n->getInteger() << endl;
cout << n->getReal() << endl;
cout << n->toString() << endl;
cout << n->isReal() << endl;
GlobalContext::getInstance()->deleteLastLocalContext();
//// fact
Function *fact = Factory::createNewFunction("", "fact");
list<string> *args = new list<string>();
args->push_back("n");
fact->setArgsNames(args);
IfThenElse *ifthen = (IfThenElse*)Factory::createNewIf("if...");
fact->setExpression(ifthen);
BinaryNumberCondition *bc = Factory::createNewLessThanOrEqual("n<=0");
Variable *v = Factory::createNewVariable("n");
v->setName("n");
bc->setLeft(v);
bc->setRight(Factory::createIntegerNumber(0));
ifthen->setBoolCondition(bc);
// if true
ifthen->setLeft(Factory::createIntegerNumber(1));
// if false
Operation *time = Factory::createTimeOperation("n*fact(n-1)");
ifthen->setRight(time);
time->setLeft(v);
Operation *sub = Factory::createSubstractOperation("n-1");
sub->setLeft(v);
sub->setRight(Factory::createIntegerNumber(1));
list<Expression*> *rec = new list<Expression*>();
rec->push_back(sub);
time->setRight(fact, rec);
//time->setRight(Factory::createIntegerNumber(5));
cout.flush();
list<Expression*> *ar = new list<Expression*>();
ar->push_back(Factory::createIntegerNumber(3));
cout << "Fact(3)=" << fact->eval(ar)->getInteger() << endl;
return 0;
}