hay.. I'm kinda new.. well... really new.. to C++. I'm wondering if theres any way for a user to input an equation. i'm working on a program that had embedded equations, the only problem is I want the user to be able to define the equations to fit their own need. i've been trying different approaches, but I can't find anything anywhere that hints on how to do this, short of strings of IF statements or strings of switches... can anyone help?
Yup, you have to parse it yourself, unless you can compile on the fly. I made a graphing program a long time ago, and you had to change the source code to get it to draw another equation, since I didn't know the solution back then (I was using BASIC). However, the problem arose on the DevShed board a few weeks ago, and after thinking about the problem newly (after about 10 years), I came up with a solution using pointers to functions, which I am going to implement myself, soon. If you are a newbie at C++, then you may wish to pass on this. But, here's the thread, if you want to look at my answer:dynamically defined functions I think it will work.
Yes,functions r the easiest way to solve operations.From simple BODMAS operations to long equations, functions r the answer.If u dont know much of OOP,make the user enter 1 value at a time and print the final answer in the end.