title: Why do we specify arrays size as a parameter when passing to function in C++?
body: <p>I searched this question, most of them says the same thing. Since we only pass the arrays address in a function, compiler can not know the arrays size by looking at the address, they say. I tried to test this by using this code, and both functions gave the same results. So, how does specifying the arrays size as a function parameter help me in a practical way?. In which conditions does specifying the size help us?.</p>
  
  <pre><code>class ArrayTest
  {
      public:
       void say(int ar[])
       {
           cout&lt;&lt;ar[1]&lt;&lt;endl;
           cout&lt;&lt;ar[7]&lt;&lt;endl;
       }
  
        void say(int ar[],int sizeAn)
       {
           cout&lt;&lt;ar[1]&lt;&lt;endl;
           cout&lt;&lt;ar[7]&lt;&lt;endl;
       }
  
  };
  
  int main()
  {
      ArrayTest test;
     int anAr[5] = {1,2,3,4,5};
     test.say(anAr);
     test.say(anAr,5);
      return 0;
  
  }
  </code></pre>