J
JKop
template<class T>
inline T& NthArrayMember( T & (array[]),size_t i)
{
return array[i - 1];
}
template<class T>
inline const T& NthArrayMember( const T & (array[]),size_t i)
{
return array[i - 1];
}
G++: declaration of `array' as array of references
I've tried about five different parenthesis combinations, but I just can't
get a reference to an array!
It's to be used as so:
int main()
{
int blah[50];
NthArrayMember(blah,45) = 56; //45th member = 56
extern void SomeFunc(int);
SomeFunc( NthArrayMember(blah,34) ); //Passes 34th member
}
-JKop
inline T& NthArrayMember( T & (array[]),size_t i)
{
return array[i - 1];
}
template<class T>
inline const T& NthArrayMember( const T & (array[]),size_t i)
{
return array[i - 1];
}
G++: declaration of `array' as array of references
I've tried about five different parenthesis combinations, but I just can't
get a reference to an array!
It's to be used as so:
int main()
{
int blah[50];
NthArrayMember(blah,45) = 56; //45th member = 56
extern void SomeFunc(int);
SomeFunc( NthArrayMember(blah,34) ); //Passes 34th member
}
-JKop