MultiType Array - Need help

 

Hi All,


I try to find solutions for my below problem. In the case I would like to define type in a different situation.

Like you see we have 2 voids and one function int. Diff type arrays are pass to func. I know it is not working for string arr now but I just wondering how can I fix that not duplicate functions.

Tried to #ifdef but Im not sure it is possible to do that method.

Im looking for var type like in c#.

Please help.


Please see example.


void test1()
{
        int arr[1];
        int size;

        size = checkarray(arr);
}

void test2()
{
        string arr[3];
        int size;

        size = checkarray(arr);
}

int checkarray(int &arr[])
{
        return(ArraySize(arr));
}
 
szczudlo6:

Hi All,


I try to find solutions for my below problem. In the case I would like to define type in a different situation.

Like you see we have 2 voids and one function int. Diff type arrays are pass to func. I know it is not working for string arr now but I just wondering how can I fix that not duplicate functions.

Tried to #ifdef but Im not sure it is possible to do that method.

Im looking for var type like in c#.

Please help.


Please see example.


template<typename T>
int CheckArray(T &arr[])
{
   return ArraySize(arr);
}