How can I return a constant string array(Which is two-dimensional), in a function defined in a header file?

I managed to return a string array in a function, but not a constant array; I WANT
to declare my array as constant as the element values will NEVER be changed -
this is why I want to return a constant string array - so my code is constant.

Please give me a simple code example.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <string>

constexpr std::size_t NROWS = 3 ;
constexpr std::size_t NCOLS = 5 ;
using array_type = std::string[NROWS][NCOLS] ;

const array_type& foo() // return reference to const
{
    static const array_type array // static
    {
        { "zero", "one", "two", "three", "four" },
        { "black", "red", "green", "blue", "white" },
        { "cat", "dog", "parrot", "cow", "deer" }
    };

    return array ;
}
Topic archived. No new replies allowed.