
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
What are postfix operators in C++?
Postfix operators are unary operators that work on a single variable which can be used to increment or decrement a value by 1(unless overloaded). There are 2 postfix operators in C++, ++ and --.
In the postfix notation (i.e., i++), the value of i is incremented, but the value of the expression is the original value of i. So basically it first assigns a value to expression and then increments the variable. For example,
Example
#include<iostream> using namespace std; int main() { int j = 0, i = 10; // If we assign j to be i++, j will take i's current // value and i's value will be increatemnted by 1. j = i++; cout << j << ", " << i << "\n"; return 0; }
Output
This will give the output −
10, 11
- Related Articles
- What are postfix operators in C#?
- What is the difference between prefix and postfix operators in C++?
- Difference between prefix and postfix operators in C#?
- What are operators in JavaScript?
- What are JavaScript Operators
- What is Postfix Notation?
- What are Arithmetic Operators in JavaScript?
- What are Comparison Operators in JavaScript?
- What are Logical Operators in JavaScript?
- What are Assignment Operators in JavaScript?
- What are Conditional Operators in JavaScript?
- What are boolean operators in Python?
- What are multiplicative operators in C++?
- What are shift operators in C++?
- What are equality operators in C++?

Advertisements