#include <iostream>
#include <string>
using namespace std;
int main(void)
{
	string washingUp[3] = { "plate","cup","bowl"};  //we can initialize an array
	int yourArray[] = { 1,2,3,4,5 };  //we can let C++ work out how many elements are in the array
	int myArray[5];// we don't have to initialise an array when we declare it
	//we can access the contents of an array
	string x = washingUp[0];  //array elements start at zero in C/C++
	cout << x << endl;
	for (int i = 0; i < 3; i++)  //loop through three elements of array
	{
		cout << washingUp[i]<<endl;
	}
	//we can assign values to an array...
	for (int i = 0; i < 5; i++)
	{
		myArray[i] = yourArray[i] + 2;
		cout << myArray[i] << endl;
	}
	//...and overwrite them, of course;
	cout << " myArray[2] contains " << myArray[2] << endl;
	myArray[2] = 75;
	cout <<" myArray[2] now contains "<<
	myArray[2] << endl;

	
	//C++ 2011 also allow the use of the for..each loop construct.
	for (string i : washingUp)
	{
		cout << i << endl;
	}
	//or 
	for (int i : myArray)
	{
		cout << i << endl;
	}

	//if we didn't know the size of the array then it is possible to query this
	//with the sizeof() operator
	int myArraySize = sizeof(myArray);
	cout <<"size of myArray in BYTES is " << myArraySize << endl;
	int intSize=sizeof(int);
	cout << "number of bytes in an int is " << intSize << endl;
	cout << "so number of elements in myArray is " << myArraySize / intSize << endl;

	//multidimentional arrays
		//arrays can also be organised like a table
		//this is called a 2 dimensional array.

	char myTable[2][3] = { 'a','b','c','d','e','f' };
	//or
	char yourTable[2][3] = { {'a','b','c'},{'d','e','f'} };
	//underneath the hood C/C++ stores arrays as a single 1D list
	//Accessing multidimensional arrays
	cout << "second row,first element is " << myTable[1][0] << endl;

	system("pause");

	return 0;
}