title: error C2352 illegal call of non-static member function
body: <p>I am creating a Heap type priority queue using a dynamically sized array. I am aware that vectors would be simpler to implement, but this is a learning exercise for me. Everything works great, but I am having issues only when attempting some Unit testing in visual studio '13.  I'm experiencing <a href="http://i.stack.imgur.com/jS5m1.png" rel="nofollow">this error</a></p>
  
  <p>Here is the source file  where I attempt to run the Unit tests:</p>
  
  <pre><code>//Prog1Test.cpp
  #include "UnitTest.h"
  #include &lt;iostream&gt;
  
  int main()
  {
      PriorityQueue Q = PriorityQueue();
      UnitTest::test1(Q);
      UnitTest::test2(Q);
      UnitTest::test3(Q);
      UnitTest::test4(Q);
      return 0;
  }
  </code></pre>
  
  <p>Here is the UnitTest.cpp: </p>
  
  <pre><code>//UnitTest.cpp
  #include "UnitTest.h"
  #include &lt;cassert&gt;
  
  void UnitTest::test1(PriorityQueue Q)
  {
      Q.clear();
      Q.append('a');
      Q.append('b');
      assert(Q.size() == 2);
      assert(Q.check() == true);
  }
  
  void UnitTest::test2(PriorityQueue Q)
  {
      Q.clear();
      Q.append('b');
      Q.append('a');
      assert(Q.size() == 2);
      assert(Q.check() == false);
  }
  
  void UnitTest::test3(PriorityQueue Q)
  {
      Q.clear();
      Q.insert('a');
      Q.insert('b');
      assert(Q.size() == 2);
      assert(Q.check() == true);
      assert(Q.remove() == 'a');
      assert(Q.size() == 1);
  }
  
  void UnitTest::test4(PriorityQueue Q)
  {
      Q.clear();
      Q.insert('b');
      Q.insert('a');
      assert(Q.size() == 2);
      assert(Q.check() == true);
      assert(Q.remove() == 'a');
      assert(Q.size() == 1);
  }
  </code></pre>
  
  <p>Here is the UnitTest header file:</p>
  
  <pre><code>//UnitTest.h
  #ifndef UnitTest_H
  #define UnitTest_H
  #include "PriorityQueue.h"
  
  class UnitTest
  {
  public:
      void test1(PriorityQueue Q);
      void test2(PriorityQueue Q);
      void test3(PriorityQueue Q);
      void test4(PriorityQueue Q);
  };
  
  
  #endif
  </code></pre>
  
  <p>Here is the PriorityQueue class header:</p>
  
  <pre><code>#ifndef PriorityQueue_H
  #define PriorityQueue_H
  
  class PriorityQueue
  {
  private:
      char *pq;
      int length;
      int nextIndex;
      char root;
  public:
      PriorityQueue();
      ~PriorityQueue();
      char&amp; operator[](int index);
      void append(char val);
      int size();
      void clear();
      void heapify();
      bool check();
      void insert(char val);
      char remove();
      friend class UnitTest;
  };
  
  
  #endif
  </code></pre>
  
  <p>here is the priorityqueue.cpp file:</p>
  
  <pre><code>#include&lt;math.h&gt;
  #include "PriorityQueue.h"
  
  
  
  
  PriorityQueue::PriorityQueue()
  {
      pq = new char[0];
      this-&gt;length = 0;
      this-&gt;nextIndex = 0;
  }
  
  
  
  
  PriorityQueue::~PriorityQueue() {
      delete[] pq;
  }
  
  
  
  
  char&amp; PriorityQueue::operator[](int index) {
      char *pnewa;
      if (index &gt;= this-&gt;length) {
          pnewa = new char[index + 1];
          for (int i = 0; i &lt; this-&gt;nextIndex; i++)
              pnewa[i] = pq[i];
          for (int j = this-&gt;nextIndex; j &lt; index + 1; j++)
              pnewa[j] = 0;
          this-&gt;length = index + 1;
          delete[] pq;
          pq = pnewa;
      }
      if (index &gt; this-&gt;nextIndex)
          this-&gt;nextIndex = index + 1;
      return *(pq + index);
  }
  
  
  
  
  void PriorityQueue::append(char val) {
      char *pnewa;
      if (this-&gt;nextIndex == this-&gt;length) {
          this-&gt;length = this-&gt;length + 1;
          pnewa = new char[this-&gt;length];
          for (int i = 0; i &lt; this-&gt;nextIndex; i++)
              pnewa[i] = pq[i];
          for (int j = this-&gt;nextIndex; j &lt; this-&gt;length; j++)
              pnewa[j] = 0;
          delete[] pq;
          pq = pnewa;
      }
      pq[this-&gt;nextIndex++] = val;
  }
  
  
  
  int PriorityQueue::size() {
      return this-&gt;length;
  }
  
  
  
  
  void PriorityQueue::clear() {
      delete[] pq;
      pq = new char[0];
      this-&gt;length = 0;
      this-&gt;nextIndex = 0;
  }
  
  
  
  
  void PriorityQueue::heapify() {
      char parent;
      char root;
      char temp;
      for (double i = this-&gt;length - 1; i &gt;= 0; i--)
      {
          root = pq[0];
          int parentindex = floor((i - 1) / 2);
          int leftchildindex = 2 * i + 1;
          int rightchildindex = 2 * i + 2;
          if (pq[(int)i] &lt;= pq[leftchildindex] &amp;&amp; pq[(int)i] &lt;= pq[rightchildindex])
          {
              pq[(int)i] = pq[(int)i];
          }
          else if (rightchildindex &lt; this-&gt;length &amp;&amp; pq[(int)i] &gt; pq[rightchildindex])
          {
              temp = pq[(int)i];
              pq[(int)i] = pq[rightchildindex];
              pq[rightchildindex] = temp;
              heapify();
          }
          else if (leftchildindex &lt; this-&gt;length &amp;&amp; pq[(int)i] &gt; pq[leftchildindex])
          {
              temp = pq[(int)i];
              pq[(int)i] = pq[leftchildindex];
              pq[leftchildindex] = temp;
              heapify();
          }
      }
  }
  
  
  
  void PriorityQueue::insert(char val) {
      char *pnewa;
      if (this-&gt;nextIndex == this-&gt;length) {
          this-&gt;length = this-&gt;length + 1;
          pnewa = new char[this-&gt;length];
          for (int i = 0; i &lt; this-&gt;nextIndex; i++)
              pnewa[i] = pq[i];
          for (int j = this-&gt;nextIndex; j &lt; this-&gt;length; j++)
              pnewa[j] = 0;
          delete[] pq;
          pq = pnewa;
      }
      pq[this-&gt;nextIndex++] = val;
      PriorityQueue::heapify();
  }
  
  
  bool PriorityQueue::check() {
      char root;
      root = pq[0];
      for (int i = this-&gt;length - 1; i &gt;= 0; i--)
      {
          if ((int)pq[i]&lt; (int)root)
              return false;
      }
      return true;
  }
  
  
  
  char PriorityQueue::remove() {
      char root = pq[0];
      char *qminus;
      qminus = new char[this-&gt;length];
      for (int i = 1; i&lt;this-&gt;length; i++)
          qminus[i - 1] = pq[i];
      pq = qminus;
      this-&gt;length -= 1;
      PriorityQueue::heapify();
      return root;
  }
  </code></pre>