What does this declaration / definition of this method mean? (something related to passing an array?)

Hi, I came across an outdated code and I came across a wierd method definition / declaration. I have a reasonable assumption that he does, but I can’t be 100% sure.

declaration:

const SomeEnumeratedId (&SomeMethod() const)[SOME_CONSTANT_VALUE];

definition

const SomeEnumeratedId (&SomeClass::SomeMethod() const)[SOME_CONSTANT_VALUE]
{
    return someMemberArray;
}

My best guess is that it passes a reference to someMemberArray and ensures that it is SOME_CONSTANT_VALUE in size, but I never saw the [] notation after declaring the method as it appears, and there are so many parentheses.

Any help is greatly appreciated.

+5
source share
3 answers

const, SOME_CONSTANT_VALUE const SomeEnumeratedId s.

typedef .

typedef const SomeEnumeratedId SomeArrayType[SOME_CONSTANT_VALUE];

SomeArrayType& SomeClass::SomeMethod() const
{
    return someMemberArray;
}
+7

, @Charles, / , , .

( ) typedef:

typedef SomeEnumerated array_t[SOME_CONSTANT_VALUE];
const array_t& SomeMethod() const;
0

, C. , typedef : typedef int myArrayType[3];, [3] , .

, {std,tr1,boost}::array - , :

 array<SomeEnumeratedId, SOME_CONSTANT_VALUE>& SomeClass::SomeMethod() const;

.

typedefs ( ) , , {std,tr1,boost}::array , typedefs.

0
source

All Articles