Simple Calc: Problem 2

Hey guys,my previous attempt at making a calculator was a dumb,so I started searching the net for some ideas.
Interestingly,the one that stood out was using a infix-2-postfix notation, or the Shunting Yard Algorithm as its known.Our teacher at school had taught us how to use this algorithm,so that wont be a problem.

What my main issue is that i want to use some functions in my calculator such as Square root,for example.But there is no key for the sign of squareroot in my keyboard,so i thought about using this character => '_/' .

This is just an example,but theres also less-than-equal sign,given by '<=' and greater-than-equal given by '>='.The problem is that should i store this as char datatype or wchar_t datatype,i cant understand.Also, using a string wont do bcoz it could make the size of the program bigger(or am I wrong? ).

Pls give some feedback on the project :) .

Heres the link :-

http://www.4shared.com/file/1Kyeu0sPba/Simple_Calctar__1_.html
Pls guys can anyone answer my question pls?? I request you guys....
using a string wont do bcoz it could make the size of the program bigger(or am I wrong? ).

The difference in the size of your program is trivial. For such a small program, it makes no practical difference.

Welcome to the wonderful world of parsing. When op codes are simple characters, this is easy as you can just use the character in a switch statement. As your op codes get more complicated, you're going to want to translate them into a representation of the token. Enums are good for this.

i thought about using this character => '_/' .

If you're using narrow characters, that's not a single character. You're going to need to represent that as a string.

Pls give some feedback on the project

Sorry. Can't access that site from work.
Last edited on
Why not learn from the experts? Here is a demo from Bjarne Stroustrup that he uses in his book.
This might give you an idea how to attack a problem.
http://www.stroustrup.com/Programming/Solutions/Ch7/e7-1.cpp
Topic archived. No new replies allowed.