title: Call function in vector of 2 class inheritance
body: <p>I'm getting into polysorphism. I'm in trouble with vector when I call function. This is my code:</p>
  
  <pre><code>Class Customer: 
  
  
  #pragma once
  #include&lt;iostream&gt;
  #include&lt;string&gt;
  #include&lt;vector&gt;
  using namespace std;
  class Customer
  {
  protected:
      string id;
      float money;
  public:
      Customer();
      ~Customer();
      virtual void Input();
      virtual void Output();
      string GetId()
      {
          return id;
      }
      void SetId(string ID)
      {
          id = ID;
      }
  };
  </code></pre>
  
  <p>Class LoyalCustomer:</p>
  
  <pre><code>#pragma once
  #include"Customer.h"
  class LoyalCustomer:public Customer
  {
      int level;  //level of relationship
  public:
      LoyalCustomer();
      ~LoyalCustomer();
      void Input();
      void Output();
  };
  </code></pre>
  
  <p>RegularCustomer:</p>
  
  <pre><code>#pragma once
  class RegularCustomer:public Customer
  {
  public:
      RegularCustomer();
      ~RegularCustomer();
      void Input();
      void Output();
  };
  </code></pre>
  
  <p>Class SuperMarket:</p>
  
  <pre><code>#pragma once
  #include"LoyalCustomer.h"
  #include"RegularCustomer.h"
  class SuperMarket
  {
      vector&lt;Customer*&gt; list;
  public:
      SuperMarket();
      ~SuperMarket();
      void FindCustomer()
      {
          string ID;
          cout &lt;&lt; "Input id of customer: ";
          cin &gt;&gt; ID;
          for (int i = 0; i&lt;list.size(); i++)
              if (ID == list[i]-&gt;GetId())
              {
                  //do something
              }
      }
      void Input()
      {
          string ID;
          cout &lt;&lt; "Input id of customer: ";
          cin &gt;&gt; ID;
          Customer *p = NULL;
          if (ID[0] == 'L')
          {
              p = new LoyalCustomer;
              p-&gt;Input();
              p-&gt;SetId(ID);
              list.push_back(p);
          }
          if (ID[0] == 'R')
          {
              p = new RegularCustomer;
              p-&gt;Input();
              p-&gt;SetId(ID);
              list.push_back(p);
          }
      }
      void Output()
      {
          //printf customer 
      }
  };
  </code></pre>
  
  <p>When I call GetID() function in FindCustomer() function in line:if (ID == list[i]->GetId()) and then I run my code, program doesn't notify error but I input "ID" to find, it doesn't find out. I don't know how to fix it. Please help me. Thanks!</p>