DEV Community

Discussion on: Part 2: Operators, User input, and if/else statements

Collapse
 
pauljlucas profile image
Paul J. Lucas

... just like “*” is an operator that represents multiplication.

It represents multiplication and pointer dereference.

It works on two or more operands and produces an output. For example 1+2+3, here the “+” operator works on three operands and produces 6 as output.

No; + works on one (for unary plus, e.g., +1) or two operands only. If you write 1+2+3, that's really (1+2)+3: the first + take the operands 1 and 2, adds them, and stores the result in a temporary, say T0; the second + takes the operands T0 and 3 and adds those. Speaking of (), you don't mention anything about operator precedence, associativity, or how () can be used to change the default.

You left out pointer, array, and bit-wise operators in your list. You're also missing several assignment operators, e.g., <<=. You also don't mention the difference between pre- and post-increment and decrement.

There's no such thing as a "nested if statement". It's just if statement [else statement]. If either of those statements just so happen to be another if, so be it. You also don't mention the common problem that else binds to the most recent if, nor how to solve that problem.

I realize you're trying to present a simple introduction, but, well, 5-year-olds are just too young a target audience. Also, if you're going to omit things for simplicity, you should at least mention them in passing, then say "more on X later."

There are innumerable "Intro to C++" sites out there. It's not clear what unique perspective yours brings to the table.