#include <iostream>
#include <string>
#include <stdlib.h>

using namespace std;

//All the members of union share same memory location
//Use for member variable that have no overlapping use
//- meaning - only if it's doesn't matter if another member override
//  another member value

union Index {
	int i;
	int j;
};

int main(void) 
{
	union Index index;
	
	for(index.i=0; index.i<5; index.i++) {
		cout << "Value of index.j: " << index.j << endl;
	}
	cout << endl;
	
	index.i = 5;
	index.j = 7;
	
	cout << "Value of index.i: " << index.i << endl;
							     
    return 0;
} 
