Mixed expression versus expression or subexpression

I feel like I am a little confused here about the differences between sub-expressions and expressions.

Compound expression - An expression that includes more than one operator.

eg. 1 + 1 * 1

Expression - An operator with one or more operands.

For example, 1 + 1or+ 1

is there a level below an expression called a subexpression?

+3
source share
4 answers

An expression may not have an operator. For example, in the following:

int a = 0;
a;

ais an expression. The expression is to quote the C ++ standard "sequence of operators and operands that define the calculation" (C ++ 03 5/1). Here ais the "operand", although there is no operator.


A subexpression is any expression that is a piece of a larger expression. So in

int a = 0, b = 0, c = 0, d = 0;
a * b + c * d;

a * b c * d .


"" , . , . , , .

"", .

+9
  • ++ , ( 5, ).

  • ++ ,

  • ++ full expression ,

:

a + 4 + 5;

a + 4 + 5 - . a, 4, a + 4 ( () ),

+6

, , : , , .

, . . , - :

int f(int const &x=2) { return x; }
int y = f()+4;

f() int, 2, f. y= f() + 4, int const &x=2 .

+4

As far as I understand from the above definitions 2+3, -4and *ptrare expressions. What could be shorter than this? Maybe only identifiers and constants such as 4.

0
source

All Articles