#include #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto MyVar = uc.DefineVariable("MyVar = 123"); auto MyAlias = uc.CreateAlias("MyAlias", MyVar); cout << uc.Eval("MyAlias") << endl; // Contains same value as MyVar uc.Eval("MyAlias = 456"); // Same as changing MyVar cout << uc.EvalStr("MyVar") << endl; // MyVar reflects change made in MyAlias cout << "" << endl; // This section below shows how you can have Alias distinguish // between different variables with the same name uc.DefineFunction("MyFunc() = MyVar + 1"); // MyVar defined below is a new variable sharing the same name // MyFunc() will still use the value of the original MyVar auto MyVarAlt = uc.DefineVariable("MyVar = 100"); // The function below uses the new MyVar variable uc.DefineFunction("MyFunc2() = MyVar + 1"); cout << uc.Eval("MyFunc()") << endl; cout << uc.Eval("MyFunc2()") << endl; cout << "" << endl; uc.CreateAlias("MyAliasAlt", MyVarAlt); uc.Eval("MyAlias = 200"); // Changes MyVar used in MyFunc() uc.Eval("MyAliasAlt = 300"); // Changes MyVar used in MyFunc2() cout << uc.Eval("MyFunc()") << endl; cout << uc.Eval("MyFunc2()") << endl; }