title: The following code is supposed to return true if i compare a1 with a2. But it is returning false
body: <pre><code>#include&lt;iostream&gt;
  #include&lt;cstring&gt;
  
  using namespace std;
  
  class Array {
  private:
      int* array;
      int s;
  public:
      Array()
          {
              array = NULL;
              s = 0;
                      
          }
      Array(int size)
          {
              size = (size &gt; 0 ? size : 10);
              array = new int[size]; 
              for (int i = 0; i &lt; size; i++)
                  array[i] = 0;
                      
          }
      Array(int* arr, int size)
          {
              for (int i = 0; i &lt; size; i++)
              {
                  *(arr + i) = *(array + i);
              
              }
          }
      Array(const Array&amp; a):s(a.s)
          {
              array = new int[s];
              for (int i = 0; i &lt; s; i++)
                  array[i] = a.array[i];
                      
          }
      int&amp; operator[](int i)
          {
              return array[i];
          }
      const Array&amp; operator=(const Array&amp; obj)
          {
              if (&amp;obj != this) { 
                  if (s != obj.s) {
                      delete[] array; 
                      s = obj.s;
                      array = new int[s]; 
                  }
              
              }
              for (int i = 0; i &lt; s; i++)
                  array[i] = obj.array[i];
              return *this;
          }
      bool operator==(const Array&amp;obj)const
          {
              if (s != obj.s)
                  return false;
              for (int i = 0; i &lt; s; i++) {
                  if (array[i] != obj.array[i])
                      return false;
              }
              return true;
          }
                  
      ~Array() {
          delete[] array;
      }
  };
  
  int main()
  {
      Array a1(5);
      int arr[] = { 1,2,3,4,5 };
      Array a2(arr, 5);
      a1 = a2;
  }
  </code></pre>
  <p>I am trying to run above program which is supposed to return true if I compare a1 and a2.but when I run this program I am getting false. Kindly check the overloaded operators
  and let me know where is the mistake. I have overloaded both assignment and equal operators but still I am not getting the actual output.</p>