// ==========================================================================
// $Id: auto_ref2014.cpp,v 1.2 2015/09/14 19:35:25 jlang Exp $
// CSI2372 example Code for lecture 3
// ==========================================================================
// (C)opyright:
//
//   Jochen Lang
//   EECS, University of Ottawa
//   800 King Edward Ave.
//   Ottawa, On., K1N 6N5
//   Canada. 
//   http://www.eecs.uottawa.ca
// 
// Creator: jlang (Jochen Lang)
// Email:   jlang@eecs.uottawa.ca
// ==========================================================================
// $Log: auto_ref2014.cpp,v $
// Revision 1.2  2015/09/14 19:35:25  jlang
// formatting fixed
//
// Revision 1.1  2015/09/14 18:21:19  jlang
// Added pointer to array and C++14 auto type inference.
//
// ==========================================================================
#include <iostream>

using std::cout;
using std::endl;

int main( ) {
  int i=3, &iRef = i;
  cout << "i = " << i << "\t";
  cout << "iRef = " << iRef << endl;
	
  auto j = iRef;
  j += 5;
  cout << "j = " << j << " but ";
  cout << "i = " << i << " and ";
  cout << "iRef = " << iRef << endl;
	
  auto &jRef = i;
  i += 1;
  cout << "i = " << i << " and ";
  cout << "jRef = " << jRef << " (reference)" << endl;
	
  decltype(auto) jRef2 = iRef;
  i += 1;
  cout << "i = " << i << " and ";
  cout << "iRef = " << iRef << " and ";
  cout << "jRef2 = " << jRef << " (reference)" << endl;

  decltype(auto) jRef3 = (i);
  i += 1;
  cout << "i = " << i << " and ";
  cout << "jRef3 = " << jRef << " (reference)" << endl;

  return 0;
}
