template<typename T, size_t N>
size_t mysizeof(T(&)[N])
{
return N;
}
On this note, here is a way to pass an array by C++ reference style where A has no l-value
void PassArrayByRef(int(&A)[10])
{
// A++; // Illegal
}
The usual way to pass an array where “A” is a pointer
void PassArrayByPtr(int A[10])
{
A++;

No comments:
Post a Comment