namespace FunctionNamespace
{
//--------------------------------------------------------\\
// GetElementCount( ). \\
// Returns the amount of elements within the given array. \\
//--------------------------------------------------------\\
template < typename ArrayType >
size_t GetElementCount( const ArrayType p_Array[ ] = NULL )
{
// Make sure that the array is valid( not NULL ).
if( p_Array != NULL )
{
// Compute the amount of elements in the array.
size_t t_stElementCount( sizeof( p_Array ) / sizeof( ArrayType ) );
// Return the amount of elements in the array.
return t_stElementCount;
}
// if the array is invalid.
elseif( p_Array == NULL )
{
// Return zero.
return 0;
}
}
//---------------------------------------------------------------------------\\
// CompareValues( ). \\
// Compares the left value with the right value. Returns true if they match. \\
//---------------------------------------------------------------------------\\
template < typename VariableType >
bool CompareValues( const VariableType &p_CmpLeft, const VariableType &p_CmpRight )
{
// Compare the two and return the result.
return( ( p_CmpLeft == p_CmpRight ) ? true : false );
}
};
Here are the errors I'm getting:
error: ISO C++ forbids declaration of 'ArrayType' with no type
error: expected ',' or '...' before 'p_Array'
In function 'size_t FunctionNamespace::GetElementCount(int)':
error: 'p_Array' was not declared in this scope
error: ISO C++ forbids declaration of 'VariableType' with no type
error: expected ',' or '...' before '&' token
In function 'bool FunctionNamespace::CompareValues(int)':
error: 'p_CmpLeft' was not declared in this scope
error: 'p_CmpRight' was not declared in this scope
Okay, this is the definition of the word "screwy". All I have to do to fix the errors is move them out of the namespace (which should not end with a semicolon), and rewrite the namespace around the moved code. I'm guessing you have some hidden characters somewhere.
EDIT: Idiot me, of course, those comments. You can't use \ in comments like that. '\' has a special meaning: it tells the preprocessor to ignore a newline right after it, and I'm guessing there was some confusion as to when your comment actually ended. All you need to do is add an extra line under your \\ed comments.