title: alphabetically sorting binary search tree in c++
body: <p>I'm new to stackoverflow, i just got desperate and am hoping for a miracle.</p>
  
  <p>I have to read in from a file a list of people with their info being
  Last name (up to 20 characters)
  First name (up to 20 characters)
  House number (an integer)
  Street (up to 20 characters)
  City (up to 20 characters)
  State abbreviation (up to 2 characters)
  Zip (a 5 digit code)</p>
  
  <p>I have to have two binary search trees, one sorted by zip code and one sorted by last name. The professor generally gives us a ton of info about the reasoning behind the code but absolutely nothing in terms of implementation. I'm pretty lost, especially when it comes to sorting strings alphabetically. I haven't even gotten to the part of the code where I read in from the file yet, but I'm trying to set up my methods first. </p>
  
  <p>Any suggestions on how to create an alphabetically ordered c++ binary search tree? Do i need two different node structs and insert methods for it to be ordered by zip and last name?</p>
  
  <p>here's my code so far</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;iterator&gt;
  #include&lt;fstream&gt;
  #include&lt;cstdlib&gt;
  
  using namespace std;
  
  class inputInfo
  {
      private:
      string tempLast;
      string tempFirst;
      int tempHouse;
      string tempStreet;
      string tempCity;
      string tempState;
      int tempZip;
  
      public:
      void setLast(string last);
      void setFirst(string first);
      void setHouse(int house);
      void setStreet(string street);
      void setCity(string city);
      void setState(string sate);
      void setZip(int zip);
  
      string getLast();
      string getFirst();
      int getHouse();
      string getStreet();
      string getCity();
      string getState();
      int getZip();
  }
      void inputInfo::setLast(string last)
      {tempLast=last;}
      void inputInfo::setFirst(string first)
      {tempFirst=first;}
      void inputInfo::setHouse(int house)
      {tempHouse=house;}
      void inputInfo::setStreet(string street)
      {tempStreet=street;}
      void inputInfo::setCity(string city)
      {tempCity=city;}
      void inputInfo::setState(string state)
      {tempState=state;}
      void inputInfo::setZip(int zip)
      {tempZip=zip;}
  
      string inputInfo::getLast()
      {return tempLast;}
      string inputInfo::getFirst()
      {return tempFirst;}
      int inputInfo::getHouse()
      {return tempHouse;}
      string inputInfo::getStreet()
      {return tempStreet;}
      string inputInfo::getCity()
      {return tempCity;}
      string inputInfo::getState()
      {return tempState;}
      int inputInfo::getZip()
      {return tempZip;}
  
  //Node structure for binary tree organized by zip   
  struct zipNode{
      inputInfo data;
      zipNode* left;
      zipNode* right;
  }   
  
  //Function to creat a new node
  zipNode* GetNewNode(inputInfo data){
      zipNode* newNode = new zipNode();
      newNode-&gt;data = data;
      newNode-&gt;left=newNode-&gt;right=NULL;
      return newNode;
  }
  //insert data in BST, returns address of root node
  zipNode* InsertZip(zipNode* root, inputInfo data){
      if(root == NULL)
      {
          root= GetNewNode(data);
      }
  
      else if(data.getZip() &lt;= root-&gt;data.getZip())
      {
          root-&gt;left=Insert(root-&gt;left,data);
      }
      else
      {
          root-&gt;right=Insert(root-&gt;right,data);
      }
      return root;
  }
  
  struct nameNode{
      inputInfo data;
      nameNode* left;
      nameNode* right;
  }   
  
  //Function to creat a new node
  nameNode* GetNewNode(inputInfo data){
      nameNode* newNode = new nameNode();
      nameNode-&gt;data = data;
      nameNode-&gt;left=newNode-&gt;right=NULL;
      return newNode;
  }
  //insert data in BST, returns address of root node
  nameNode* InsertName(nameNode* root, inputInfo data){
      if(root == NULL)
      {
          root= GetNewNode(data);
      }
  
      else if(data.getLast() &lt;= root-&gt;data.getLast())
      {
          root-&gt;left=Insert(root-&gt;left,data);
      }
      else
      {
          root-&gt;right=Insert(root-&gt;right,data);
      }
      return root;
  }
  </code></pre>