C++/Language/Prefix postfix

Материал из C\C++ эксперт
Версия от 10:28, 25 мая 2010; Admin (обсуждение | вклад) (1 версия: Импорт контента...)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Effects of prefix and postfix notation

#include <iostream>
using namespace std;
int main()
{
   int i(12), j(18);
   cout << i++ << endl;
   cout << i++ << endl;
   cout << i   << endl;       
   cout << j-- << endl;       
   cout << --j << endl;
   cout << --j << endl;
   return 0;
}


Example of using the postfix and prefix

#include <iostream>
using namespace std; 
int main( void )
{
     int var1 = 0, var2 = 0;
     cout << var1++ << endl;
     cout << ++var2;
     return 0;
}