   how do you pass arrays to a function
  pls tell me how do you do the same...........   
  In what language?   ;  In c++, its : int myFunc(int Array[], int aSize);note: Array could be any valid data type as well as the functionyou call it like this :int main(){    //do stuff   int Array[4] = {0};  //Call function and pass the array   myFunc(Array); //no need for the brackets,[], what its doing is passing its address}in c# its : public static void myFunc(int[] Array, int aSize) { //do something... };;  Note that arrays of different sizes are different data types. There are two solutions:a) pass a pointer to the first element and the size of the arrayb) make a function template with size as the template parameterThe b) solution looks like this:template<size_t size>void function(int (&array)[size]){    std::cout << "You passed an array of " << size << " elements\n";}int main(){    int array[] = {2, 3, 5, 7, 11, 13};    function(array);};  Can someone explain how b) works without explicitly passing the size of the aray as a template argument please?   ;Quote:Original post by yaustarCan someone explain how b) works without explicitly passing the size of the aray as a template argument please?But it already does that.   ;Quote:Original post by yaustarCan someone explain how b) works without explicitly passing the size of the aray as a template argument please?An array includes the size as part of its type information. This is necessary, particularly for multi dimensional array indexing. The compiler can infer this from the template when an array reference is passed. This might also means that the compiler will generate different copies of the function for different sized arrays.   ;  Its called (automatic) template parameter deduction and is a c++ feature. It works with any template parameter as long as the compiler has enough information to deduce the type of the parameter.template < typename T >void Foo ( T t ){// code}main(){int i = 0;Foo ( i );}   ;Quote:Original post by DevFredNote that arrays of different sizes are different data types. There are two solutions:a) pass a pointer to the first element and the size of the arrayb) make a function template with size as the template parameterThe b) solution looks like this:template<size_t size>void function(int (&array)[size]){    std::cout << "You passed an array of " << size << " elements\n";}int main(){    int array[] = {2, 3, 5, 7, 11, 13};    function(array);}never knew you could do this - huh! Thanks for that.   ;Quote:in c# its : public static void myFunc(int[] Array, int aSize) { //do something... };You don't need the size. in c#, an array stores its size :void myFunc(int[] Array) {    int Size = Array.Length; }