From the course: C++ Essential Training
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Common operators - C++ Tutorial
From the course: C++ Essential Training
Common operators
- [Instructor] There are a few very common operators that you're probably already familiar with. For completeness sake, let's go over them quickly. This is operators.cpp from chapter five of the exercise files. The assignment operator is used to copy a value from one object to another. So we can come down here and we can say x equals y. And then go ahead and print x. And when I build and run this, you'll notice well, we have our initial values of 5 and 47. So we have x equals 5 and x equals 47. And then we assign y to x using the assignment operator, and we have x equals 47. The assignment operator's also called the copy operator. And in this case, it copies the value from y into x. There's also the standard four function arithmetic operators. We can say x equals y plus x. And we'll get the sum, which should be what? 52, yeah, 52. Or we can say x equals y minus x. And we'll get 42. And we have…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.