title: C++ Code Error and I need help solving it
body: <p>so I need some help understanding how to fix this error in the terminal: </p>
  
  <pre><code>String.cpp: In constructor ‘String::String()’:
  String.cpp:16:1: error: uninitialized const member in ‘const int’ [-fpermissive]
   String::String()
   ^
  In file included from String.cpp:12:0:
  String.h:16:13: note: ‘const int String::max_length’ should be initialized
     const int max_length;
               ^
  String.cpp: In constructor ‘String::String(char*)’:
  String.cpp:21:1: error: uninitialized const member in ‘const int’ [-fpermissive]
   String::String(char str[])
   ^
  In file included from String.cpp:12:0:
  String.h:16:13: note: ‘const int String::max_length’ should be initialized
     const int max_length;
  </code></pre>
  
  <p>This is the String.cpp class in which I have to implement my own string class using only primitive data types from a header class called String.h. </p>
  
  <pre><code>String.cpp:
  #include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;string&gt;
  #include "String.h"
  
  using namespace std;
  
  String::String()
  {
      _length = 0;
  }
  
  String::String(char str[])
  {
      int i = 0;
      _length = 0;
          while(str[i] != '\0')
          {
              data[i] = str[i];
              i++;
              _length++;
          }
      data[i] = '\0';
  }
  
  void String::print()
  {
      if(_length == 0)
          cout&lt;&lt;"NULL"&lt;&lt;endl;
          for(int i = 0; i &lt; _length; i++)
              cout&lt;&lt;data[i];
              cout&lt;&lt;endl;
  }
  
  int String::length()
  {
      return _length;
  }
  
  void String::clear()
  {
      _length = 0;
  }
  
  bool String::empty()
  {
      if(_length == 0)
          return true;
      return false;
  }
  
  char String::at(int index)
  {
      return data[index];
  }
  
  int String::find(char substr[], int startIndex)
  {
      int subLen = 0;
      while(substr[subLen] != '\0')
          subLen++;
          for(int i = 0; i &lt; _length - subLen; i++)
          {
              bool match = true;
              for(int j = 0; j &lt; subLen; j++)
                  if(data[i+j] != substr[j])
                  {
                      match = false;
                      break;
                  }
                  if(match)
                      return i;
          }
      return -1;   
  }
  
  bool String::equal(String &amp;two)
  {
      if(_length != two.length())
          return false;
          for(int i = 0; i &lt; _length; i++)
              if(data[i] != two.at(i))
              return false;
          return true;   
  }
  
  bool String::add(String &amp;two)
  {
      for(int i = 0; i &lt; two.length(); i++)
          data[_length++] = two.at(i);
          data[_length] = '\0';
      return true;
  }
  
  
  String.h: 
  using namespace std;
  
  class String 
  {
      private:
  
          const int max_length;
          int _length;
          char data[256];
          int getCharArraySize(char arr[]);
  
      public:
  
          String();
          String(char str[]);
  
          void print();
          int length();
          void clear(); 
          bool empty();
          char at(int index); 
          int find(char substr[], int startIndex);
          bool equal(String &amp;two);
          bool add(String &amp;two);
  
  
  };
  </code></pre>