title: C++ Error when creating new array: Expression must have pointer to object type
body: <p>I am trying to create a new array with positive values only taken from a already created array, and when I am looping through the original array, the index has an error "Expression must have pointer to object type" I tried doing research on the error, and everyone's situation is different when getting this error so I am on my own with this. Here is my code:</p>
  
  <pre><code>int foo::createNewArray() const {
      int newarray[50];
      int oldarray = oldarray[values];
      int size = (sizeof(oldarray));
  
      for (int i = 0; i &gt; size; i++){
          if (oldarray[i] &gt; 0)
              newarray[i] = oldarray[i];
      }
  </code></pre>
  
  <p>The "i" above is what has the error. the oldarray[values] is declared in a seperate class file. Here is the small section of the code where it comes from.</p>
  
  <pre><code>        class foo{
          int oldarray[1];
          enum unit {values};
  
          public:
          int createNewArray() const;
  };
  </code></pre>