How to make scientific calculator in OOP c++

my project is scientific calculator in OOP c++.
i'm performs like this(e.g sin(2+5-4*9/1))calculate and ans me.
How to develop plz give examples.
create class with all required functions.How else?

Use member functions for calculations.

You try first and then we will guide you through
The best way is to convert your expression from an infix expression to a postfix expression and then use a stack to evaluate the expression. If you don't know what the bold words mean, Google them up.

Further, the way you want to proceed depends on whether you want it to use variables or not.

Eg. If you enter 'x^2+x+2' and expect the computer to ask 'what is x?', the approach is different.
Last edited on
The amount of code that goes in varies on the quality of the calculator. If you want to make a calculator that only has infix operators (i.e. no functions like sin), then it can be done without OOP and using only 2 to 4 functions.

But if you want to make a high quality calculator with not only expression evaluation with variables but features like numerical differentiation and integration and compatibility with all types like int, double, bool, std::complex, matrices, vectors, etc, then you'll have to write a lot of code.

I tried to make the good one a few months back. It's complete (except there's no domain checking in functions) and I had to write 74 kb of code.
Last edited on
Topic archived. No new replies allowed.