View Single Post
  #3 (permalink)  
Old April 1st, 2011, 02:00 AM
kfateh kfateh is offline
Registered User
 
Join Date: Dec 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 . . .
Reply With Quote