title: by overloading [], how to assign values to the second array member in a class?
body: <p>I am a learner. I am working on operator overloading. I am writing a code that has the below items:
  1. A class with two member arrays
  2. Overloaded [] function
  If my class has just one array member, I can overloaded [] to assign the values. But what can I do assign the values to the second member array. Here is my code below:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cassert&gt;
  class Digit
  {
  private:
      int digit1[3]{0};
      int digit2[4]{0};
  
  public:    
      int&amp; operator[](const int index);
  
      ostream&amp; operator&lt;&lt;(ostream&amp; out);
  };
  
  int&amp; Digit::operator[](const int index)
  {
      return digit1[index];
  }
  
  ostream&amp; Digit::operator&lt;&lt;(ostream&amp; out)
  {
      int loop;
      out &lt;&lt; "{";
      for (loop = 0; loop &lt; 10; loop++)
      {
          out &lt;&lt; digit1[loop] &lt;&lt; " ";
      }
      out &lt;&lt; "}";
  
      return o;
  }
  
  int main()
  {
      using namespace std;
  
      Digit n;
      n[0] = 4;
      n[1] = 3;
      n[2] = 4;
  
  
      n &lt;&lt; cout;
  
      return 0;
  }
  </code></pre>
  
  <p>In the above code, how can I overloaded [] to assign values for digit2[4]?</p>