Following is also an interesting example for those who are new in c/c++.
Code:
// PostFix_PreFix.cpp : Defines the entry point for the console application.
//
// Author: kFateh
// Date: Fri, April 01, 2011
// Description: Demonstrates postfix and prefix operator ++
// Note: Run it from inside of visual C++
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int a = 0;
int b = 0;
a = b++ + b;
cout << endl << a << ", " << b; // outputs 0, 1
a = 0;
b = 0;
a = ++b + b;
cout << endl << a << ", " << b; // outpust 2, 1
cout << endl;
return 0;
}
Output from above program
Quote:
0, 1
2, 1
Press any key to continue . . .
|