title: Towers of Hanoi with Classes
body: <p>I keep getting the Error C2228 left of '.topDisk' must have class/struct/union and I have no idea what it means, or even how to fix it, even after some research. Is it possible for someone to explain what the error is and how to fix it? I think I've provided you with all the code you need.</p>
  
  <p>HanoiPegClass.cpp File</p>
  
  <pre><code>//A function moving one disk from one peg to another
  void moveDisk(Peg&amp; beginning, Peg&amp; destination)
  {
      assert(beginning.getNumDisks() &gt; 0);
      if (destination.getNumDisks() &gt; 0)
      {
          //Where the error is
          assert(beginning.getNumDisks.topDisk() &lt; destination.getNumDisks.topDisk());
      }
  
      destination.addDisk(beginning.topDisk());
      beginning.removeDisk();
  }
  </code></pre>
  
  <p>Peg.cpp File</p>
  
  <pre><code>//Function to return the disk count (amount of discs on each peg)
  unsigned int Peg::getNumDisks() 
  {
      return diskStack.size();
  }
  
  //Function to return the value of the top disk
  int Peg::topDisk()
  {
      return diskStack.back();    
  }
  </code></pre>
  
  <p>Peg.h File</p>
  
  <pre><code>#pragma once
  #include &lt;vector&gt;
  #include &lt;string&gt;
  using namespace std;
  
  class Peg
  {
  
  private:
      vector&lt;int&gt; diskStack;
      string pegName;
      void setName(string name);
  public:
      Peg(string name, int totalDisks);
      unsigned int getNumDisks();
      void printDisks();
      string getName();
      int topDisk();
      void addDisk(int totalDisks);
      int removeDisk();
      ~Peg();
  };
  </code></pre>