I am a bit new to C++, but I am trying to make a string variable such as
string fx;
fx = "2*x + 1";
I am wanting to set x to a certain value, lets say x = 1 for now and I want to somehow return 2*1 + 1 which is 3.
To all who is familiar with MATLAB, it is the equivalent to the following code:
a = 1;
fx = 2*x + 1;
subs(fx, x, a);
disp(fx)
Is there a way to do this in C++?
You have to write the code yourself to parse the string and perform the computation.
I suggest looking up "Reverse Polish Notation", converting the string to that, and
solve.