What does the '-->' operator mean in C++ and why does it work?
Hi everyone! I'm learning C++ and came across some strange code on the internet. It was something like:
```cpp
int x = 10;
while (x --> 0) {
printf("%d ", x);
}
```
And this code works! It prints numbers from 9 to 0. At first I thought it was some new "arrow operator" that I missed in the textbook. But then I tried writing `x --> 0` without spaces as `x-->0` — it also works. But `x->0` doesn't — it gives a compilation error.
I looked into the C++ documentation and couldn't find any mention of the `-->` operator. The C++ standard has operators `->` (member access via pointer), `--` (decrement), but no `-->`. How is this even possible? Is it some compiler trick or a standard feature? Why does the code with `while (x --> 0)` compile and work, even though such an operator doesn't exist?
No answers yet.
Log in to leave an answer
Blogs
HTTP Client in PHP: Making Requests the Right Way
Top Mistakes of Beginner Go Developers: From A to Z
Code Review in Swift: What to Check and How to Give Feedback to Beginners
gRPC in JavaScript: When to Use It and How It Will Speed Up Your Project