Q:

C++ scoping? issue when passing an array to a function

Consider the code below. This generates the following output:
Length: 64
Testfn: 8
Length again: 64
I am having trouble understanding why the output at the test-function is not equal to the output at the main function. Taking into account that the output at the test-function is equal to 8, I assume that this is because sizeof(arg) gets the size of the pointer instead of the array itself.
This would all seem very logical to me, but why doesn't sizeof give that same value in the main function? And how would I fix it? I have tried several things with dereferencing, but this does not seem to give any difference whatsoever.
#include <iostream>

void test(int arg[]) {
    std::cout << "Testfn: " << sizeof(arg) << std::endl;
}

int main() {
    int int_arr[16];
    std::cout << "Length: " << sizeof int_arr << std::endl;
    test(int_arr);
    std::cout << "Length again: " << sizeof int_arr << std::endl;
}

A:

The function parameter
void test(int arg[]) {

is adjusted to pointer to type int. That is the following function declarations 
void test(int arg[16]);
void test(int arg[]);
void test(int *arg);

are equivalent.
So inside the function there is used sizeof( int * ) that depending on the using platform usually equal to either 4 or 8.
You could declare the function in C++ like
void test(int ( &arg )[16]) {
    std::cout << "Testfn: " << sizeof(arg) << std::endl;
}

that is to declare the parameter as reference to the array and in this case you will get the expected result.

