Regarding your question on std::array...
Click here if you don't know what std::array is (requires TR1 or C++11).
Code:
#include <array>
#include <iostream>
void foo(std::array<int, 5> arr)
{
arr[0] = 5;
}
int main()
{
std::array<int, 5> arr = { 1, 2, 3, 4, 5 }; // Requires C++11 initializer lists*
foo(arr);
std::cout << arr[0] << std::endl; // Prints 1 because a copy of arr was passed to foo.
}
Code:
#include <array>
#include <iostream>
void foo(std::array<int, 5>& arr)
{
arr[0] = 5;
}
int main()
{
std::array<int, 5> arr = { 1, 2, 3, 4, 5 }; // Requires C++11 initializer lists*
foo(arr);
std::cout << arr[0] << std::endl; // Prints 5 because a reference of arr was passed to foo.
}
*) Known supported compilers: gcc