title: How can I initialize the const char array member of the class using initialization list?
body: <pre><code>#include&lt;iostream&gt;
  
  using std::cout;
  using std::endl;
  
  /*
  This example aims to test whether the default copy constructor and default assignment operator works for classes that has array member and whether initialzation list works for array member.
  
  Test result: copy constructor and default assignment operator works for classes that has array member
                           initialization list doesn't work for array member.
  */
  
  class A{
      private:
          const char list[10];
      public:
          A(const char *l="Nothing");
          void show()const;
  
  };
  
  A::A(const char*l):list(l){           //the compiler fails to initialize "list"
  }
  
  void A::show()const{
      for(int i=0;i&lt;10;i++){
  
          cout&lt;&lt;list[i]&lt;&lt;'\t';
          if(i%5==4)
              cout&lt;&lt;endl;
          }
      cout&lt;&lt;endl;
  }
  
  int main(){
      char name[10]="hello";
      A a(name);
      A b;
      cout&lt;&lt;"Before assignment, b="&lt;&lt;endl;
      b.show();
      b=a;
      cout&lt;&lt;"After assignment, b="&lt;&lt;endl;
      b.show();
      A c(a);
      cout&lt;&lt;"After initialization, c="&lt;&lt;endl;
      c.show();
  
  }
  </code></pre>
  
  <p>The program fails to compile and throws an error message, saying that"incompatible types in assignment of 'const char*' to 'const char[10]". How can I achieve in initializing the const member list?</p>