+ 1

C++ Increments and decrements

Hey guys Struggling like hell on incrementing and decrementing variables. It's really confusing me and I just can't get my head around the concept. int x; int y; x=5 y=x++ ????????? wtf ?!! (where would I ever use this) ? Thanks for your help

1st Aug 2018, 11:22 PM
harry
2 ответов
+ 3
Your coded example would probably not get used. A usable example might be having an accountNumber holding the last number assigned to an account. When you create a new account, you'd increment the number before assigning like: Account account = new Account(++accountNumber);
2nd Aug 2018, 12:02 AM
John Wells
John Wells - avatar