Preprocessor Directives

hey guys, can any one guide me how to use '+', '-', '*' as preprocessor directives??
I want to do the following work.
1
2
3
#define + 10
#define - 20
#define * 30 

You cannot do that. Macro names should be valid identifiers (usable as variable names for example)

What are you trying to achieve by redefining + symbol? It will break almost everything.
I am making a program for expression evaluation. I was trying to define these implement the precedence function more easily. Can I do this in a separate class???
No. In fact you should not use defines in C++.

Open any code you wrote before and which is working.
Search for "find and replace" functionality in your IDE. It "what to replace" field write "+"; in "replace with what" field write "10". Press Replace. That what define does.

You will need to implement precedence some other way.
Once I used vector of strings where higher precedence operators were stored first and same precedence were stored in same string.
Thanks alot for your time and help.. I learned alot from you.
Topic archived. No new replies allowed.