cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
binary - operator (subtraction) and a u
binary - operator (subtraction) and a unary - operator (negation)
Dec 12, 2017 at 5:31am UTC
masterinex
(181)
how can i let the computer distinguish between a binary + operator (addition) and a unary + operator (identity) and between a binary - operator (subtraction) and a unary - operator (negation) ?
for example if i have -(-3--4)-5
the tokens would be:
negation negation 3 subtraction negation 4 subtraction 5 ?
Dec 12, 2017 at 6:05am UTC
JLBorges
(13770)
For
-(-3--4)-5
we would get an error.
The C++ parser is a greedy parser; the
--
here is the prefix decrement operator.
This is fine:
-(-3- -4)-5
and would be parsed as outlined in your post.
Topic archived. No new replies allowed.