/*------------------------------------------------------------------------- | The software accompanies the paper | | | | Classes and Objects of Chemical Thermodynamics in Object-Oriented | | Programming. 2. A Class of Chemical Species | | | | E.B. Rudnyi | | E-mail: rudnyi@comp.chem.msu.su | | Homepages: http://www.chem.msu.su/~rudnyi/welcome.html | | | | presented at Second Electronic Computational Chemistry Conference, | | November 1995, http://hackberry.chem.niu.edu/ECCC2/ | --------------------------------------------------------------------------*/ #include #include "func_tp.h" #include "memtst.h" void print_func_Tp(func_Tp& t) { if (t) cout << "function " << t << "; " << "current errno " << t.errno << ", number of characters " << t.len() << endl; else cout << "function is not determined" << endl; } int main() { memory test; func_Tp a("exp(T) + p^2"); print_func_Tp(a); cout << "result at T=1 and p=2 is " << a(1, 2) << endl << endl; func_Tp b("T + 4.5*p"); print_func_Tp(b); cout << "result at T=1 and p=2 is " << b(1, 2) << endl << endl; func_Tp c = a + b; print_func_Tp(c); cout << "result at T=1 and p=2 is " << c(1, 2) << endl << endl; b = a; print_func_Tp(b); cout << "result at T=1 and p=2 is " << b(1, 2) << endl << endl; b = "4.5*T + 2.5/p"; print_func_Tp(b); cout << "result at T=1 and p=2 is " << b(1, 2) << endl << endl; b.clear(); print_func_Tp(b); cout << "result at T=1 and p=2 is " << b(1, 2) << endl << endl; do { double T, p; cout << "your function in T and P (at the end put the symbol ':')" << endl; cin >> a; print_func_Tp(a); if (a) { cout << "values of T and p "; cin >> T >> p; cout << "result at T=" << T << " and p=" << p << " is " << a(T, p) << endl << endl; } } while (a); return 0; }