title: Initializer lists: copy constructors and assignment operators = redundancy?
body: <p>It seems that initalizer lists are a <a href="https://stackoverflow.com/questions/1598967/benefits-of-initialization-lists">good idea</a> for your class constructors and, I'm assuming, for the copy constructor as well. For the assignment operator one has to assign each member in the body of the function. Consider the following simple block:</p>
  
  <pre><code>class Foo {
  private: 
    int a,b;
  public:
    Foo(int c, int d)  : a(c), b(d) {}
    Foo(const Foo &amp; X) : a(X.a), b(X.b) {}
    Foo&amp; operator=(const Foo&amp; X) {
      if (this == &amp;X) return *this;
      a = X.a;
      b = X.b;
      return *this;
    }
  };
  </code></pre>
  
  <p>If a class has a moderate amount of data members, there are three places where one can mess up the the different assignments/initialization. By that I mean, what if the copy constructor looked like:</p>
  
  <pre><code>  Foo(const Foo &amp; X) : a(X.a), b(X.a) {}
  </code></pre>
  
  <p>or a line was missing from the operator=. Since the assignment operator and the copy constructor often have the same effect (in that we copy members from one Foo to another) can I "reuse" the code from the copy constructor or the assignment operator or vice versa? </p>