Say i have a string var x = 2 + 3 ; i can convert it into expression in javasript using eval(); is there any way to convert string into executable c++ expression same as eval ( using built-in function or customize code ) ? what i mean to do is try to find out result of a one variable linear equation . I found this code in c++ forum
#include <iostream>
struct VAR{
    float i;
};
struct LINE{//k*x+a
    float a, k;
    VAR* x;
    LINE(){}
    LINE(int a) : a(a), k(0), x(0) {}
    LINE(VAR& v) : a(0), k(1), x(&v) {}
};
LINE operator + (LINE A, LINE B){//assumes that A.x == 0 or B.x == 0 or A.x == B.x
    LINE R;
    R.a = A.a + B.a;
    R.k = A.k + B.k;
    if(A.x) R.x = A.x;
    else R.x = B.x;
    return R;
}
LINE operator - (LINE A, LINE B){//same as +
    LINE R;
    R.a = A.a - B.a;
    R.k = A.k - B.k;
    if(A.x) R.x = A.x;
    else R.x = B.x;
    return R;
}
LINE operator * (LINE A, LINE B){//assumes that A.x == 0 or B.x == 0
    LINE R;
    R.a = A.a * B.a;
    R.k = A.k * B.a + B.k * A.a;
    if(A.x) R.x = A.x;
    else R.x = B.x;
    return R;
}
LINE operator / (LINE A, LINE B){//assumes that B.x == 0
    LINE R;
    R.a = A.a / B.a;
    R.k = A.k / B.a;
    R.x = A.x;
    return R;
}
void operator == (LINE A, LINE B){
    LINE C = A - B;
    C.x->i = -C.a/C.k;
}
int main(){
    VAR x;
    5 == (2 + (x-7)*10)/2;
    std::cout << "x = " << x.i;
    std::cin.get();
    return 0;
}
its work fine. Now what i want to do is execute this "5 == (2 + (x-7)*10)/2;" statement as eval in c++ .
Edit 1: Thank you all , problem is solved :)
 
    