#include #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto x_var = uc.DefineVariable("x"); auto i = 0; // --- Inefficient Way --- cout << "--- Inefficient: Eval() in a loop ---" << endl; for ( i = 1; i <= 3; i++) { x_var.Value(i); cout << uc.Eval("x * x + 2") << endl; } cout << "" << endl; // --- High-Performance Way --- cout << "--- Efficient: Parse() once, Evaluate() in a loop ---" << endl; // Parse outside the loop auto expr = uc.Parse("x * x + 2"); for ( i = 1; i <= 3; i++) { x_var.Value(i); // Evaluate the pre-parsed object cout << expr.Evaluate() << endl; } }