This a bit tricky. To start with, you don't want to put the definition
of the array in the header. This results in an instance of the array in
every translation unit which includes the header, most of which will
never be used. And I'd definitly use a typedef.
If the only way you access this array is through the
return value of the function you ask about, then all you need in the
header is a declaration for the function:
typedef TPair <char, char> CharPairArray[3];
CharPairArray const& getArray( bool condition );
(Without the typedef, the function declaration is:
TPair <char, char> const (&getArray( bool condition ))[3];
This is a route you don't want to go.)
If you also need to access the arrays otherwise, you need to add:
extern CharPairArray const array1;
extern CharPairArray const array2;
Then, is some source file (only one), you define the functions and the
arrays:
CharPairArray const array1 = { /* ... */ };
CharPairArray const array2 = { /* ... */ };
CharPairArray const&
getArray( bool condition )
{
return condition ? array1 : array2;
}
If you don't use the extern in the header, you can put the actual
arrays in an unnamed namespace.