From the course: Complete Guide to C++ Programming Foundations
Expressions and assignments - C++ Tutorial
From the course: Complete Guide to C++ Programming Foundations
Expressions and assignments
- [Instructor] Now, let's talk about three important components of C++. Let's start by recalling what expressions are. An expression is a symbolic representation of a calculation, like the expressions you see in algebra. An expression may contain variables, constants, and operators. And an expression must produce a value. Now, let's talk about assignments. An assignment is a line of code that assigns a value to a variable. It must contain a left-hand-side and a right-hand-side expression. The left-hand-side expression must be able to hold a value and the data types of both expressions must match. This last point is not enforced by the compiler, as you saw when we assigned the negative number to an unsigned variable. So, you as a programmer are responsible of keeping your code consistent.