// ==========================================================================
// $Id: lrvalue.cpp,v 1.1 2016/09/19 18:25:19 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@site.uottawa.ca
// ==========================================================================
// $Log: lrvalue.cpp,v $
// Revision 1.1  2016/09/19 18:25:19  jlang
// added lvalue/rvalue example
//
// ==========================================================================
#include <iostream>

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


int foo() {
  int i;
  cout << "Enter an integer: ";
  cin >> i;
  return i;
}


int main() {
  // i is assigned the result of foo()
  int i=foo();
  // i is LValue which we can address of
  int *j = &i;

  // array[1] is LValue 
  int array[3];
  array[1] = 2;
  // *(array+2) is also a LValue
  *(array+2) = 3;
  *array = 1;
  for (int a:array) {
    cout << "a=" << a << endl;
  }

  // prefix operator yields LValue
  cout << "i=" << i << endl;
  ++i *= 3;
  cout << "i=" << i << endl;
  
}
