I am trying to understand thoroughly the difference between a statement and an expression
But i am finding it confusing even after reading this answer
Expression Versus Statement
look at the following:
std::cout << "Hello there? " ;
I could say that it is a statement as it is ending with a semi- colon BUT i could also say
It is an expression since i have an ostream , an output operator and a string literal
and this expression yields a value which is the left hand operand.
Which one is correct?
<<
is predefined operator forcout
. Don't get it for example of statement and expression - it is more a demonstration for predefined operator in C++. Lookprintf
function and normal expressions (with variables and constants). – Minh