title: Messy and wrong char visualization (after passing actual parameters) C++
body: <p>this is my first post. Below the code of my implementation of a char Stack. Theoretically It should print f,g,h. But when I execute it, I can just see a long list of strange signs in the console. Is a compiler issue or code issue? Thanks.</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  const int max_L = 10;
  class Stack {
  protected:
      char array[];
  int length;
  public:
      Stack(){length = 0;}
      bool push(char c) {
          if(length &lt; max_L){
              array[length] = c;
              length++;
              return(true);
          }
          else return(false);
      }
      void pop(){
          if(length &gt;= 1){
              cout &lt;&lt; array[length];
              length--;
          } else return ;
      }
      bool is_empty(){
          return(length == 0);
      }
      void print(){
          for(int i = 0; i &lt; length; i++){
              cout &lt;&lt; array[i];
          }
      }
  
   };
  
   int main() {
      Stack p1;
      p1.push('f');
      p1.push('g');
      p1.push('h');`
      p1.print();
      return 0;
   }
  </code></pre>