N
Nan Li
Please look at the code and run below. My question is why the compiler
cannot figure out the size of the array in function foo? Is this a bug
or expected?
Thanks a lot.
#include <iostream>
using namespace std;
int a[] = { 1, 2 };
void foo( int a[2] )
{
cout << sizeof( a ) << endl;
}
int main()
{
cout << sizeof( a ) << endl;
foo ( a );
}
[nan@xxx xxx]$ g++ test.cxx && ./a.out
8
4
cannot figure out the size of the array in function foo? Is this a bug
or expected?
Thanks a lot.
#include <iostream>
using namespace std;
int a[] = { 1, 2 };
void foo( int a[2] )
{
cout << sizeof( a ) << endl;
}
int main()
{
cout << sizeof( a ) << endl;
foo ( a );
}
[nan@xxx xxx]$ g++ test.cxx && ./a.out
8
4