Explaining the difference between an expression and an expression in C ++

I'm trying to fully understand the difference between an expression and an expression. But I find it confusing even after reading this answer. Expression versus expression
look at the following:

std::cout << "Hello there? " ;  

I could say that this statement since it ends with sem-colon , but I can also say that This expression, since I have ostream , an output operator and a string literal
and this expression gives a value that is the left operand.
Which one is correct?

+4
source share
3 answers

, ++:

statement:
  labeled-statement
  attribute-specifier-seq_opt expression-statement
  attribute-specifier-seq_opt compount-statement
  attribute-specifier-seq_opt selection-statement
  attribute-specifier-seq_opt iteration-statement
  attribute-specifier-seq_opt jump-statement
  declaration-statement
  attribute-specifier-seq_opt try-block

expression-statement:
  expression_opt ';'

, ; , " ", ( ) , . ,

std::cout << "Hello there? "

- ,

std::cout << "Hello there? " ;

- .

+9

?

: . C ++ , .

:

x++;       // post-increment produces a value which you could use
a = 5;     // Assignment produces a value
max(a, b); // Call of a non-void function is an expression
2 + x;     // This calculation has no side effects, but it is allowed

, C ++, . , Java #.

+5

C (6.5 )

1 , . .

-, . ++

expression-statement:
expression opt;

.

C ++. ++ , C . ++ , C . , C .

++

Label:
int x;

Label: ;
int x;
+2
source

Source: https://habr.com/ru/post/1568601/


All Articles