title: Only the first derived class is being included
body: <p>I'm new to C++, and for a school assignment we have to create a base class and create 2 derived classes from it, then display the output of all the associated functions of the two derived classes.</p>
  
  <p>The problem is, when I try to include the two derived classes in my test file, only the one that I include first works. If I reverse the order that I include them, then the one that's now included first works, but the second one doesn't</p>
  
  <p>Any ideas why this might be happening?</p>
  
  <p>Here's my test file: </p>
  
  <pre><code>#include "Payment.h"
  #include "CashPayment.h" // This one will work
  #include "CreditCardPayment.h" // This one won't. Unless you switch them
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  // Tests the CashPayment and CreditCardPayment classes, derived from the Payment clas
  int main() {
  
     CashPayment firstCash(420);
     cout &lt;&lt; "First Cash Payment" &lt;&lt; endl 
        &lt;&lt; "Amount: " &lt;&lt; firstCash.getAmount() &lt;&lt; endl
        &lt;&lt; firstCash.paymentDetails() &lt;&lt; endl;
  
     CreditCardPayment firstCredit("Mingwu Chen", 123456789, 11, 2016, 100);
     cout &lt;&lt; "Number: " &lt;&lt; firstCredit.getNumber() &lt;&lt; endl
        &lt;&lt; "Month: " &lt;&lt; firstCredit.getMonth() &lt;&lt; endl
        &lt;&lt; "Year: " &lt;&lt; firstCredit.getYear() &lt;&lt; endl
        &lt;&lt; "Amount: " &lt;&lt; firstCredit.getAmount() &lt;&lt; endl
        &lt;&lt; firstCredit.paymentDetails() &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Here's my CashPayment.h file:</p>
  
  <pre><code>#ifndef CASHPAYMENT_H
  #define CASHPAYMENT_H
  
  #include &lt;string&gt;
  #include "Payment.h"
  using namespace std;
  
  class CashPayment: public Payment {
  
     public:
  
        // Creates a CashPayment with an amount of 0
        CashPayment();
  
        // Creates a CashPayment with the given amount
        CashPayment(double a);
  
        // Creates a string out of all the CashPayment details
        string paymentDetails();
  };
  #endif
  </code></pre>
  
  <p>Here's the CreditCardPayment.h file:</p>
  
  <pre><code>#ifndef CASHPAYMENT_H
  #define CASHPAYMENT_H
  
  #include &lt;string&gt;
  #include "Payment.h"
  using namespace std;
  
  class CreditCardPayment: public Payment {
  
     private:
        string name;
        int cardNumber;
        int expMonth;
        int expYear;
  
     public:
  
        // Creates a CreditCardPayment with an amount of 0
        CreditCardPayment();
  
        // Creates a CreditCardPayment with the given card holder name, card number, expiry month, expiry year, and amount
        CreditCardPayment(string n, int c, int m, int y, double a);
  
        // Creates a string out of all the CreditCardPayment details
        string paymentDetails();
  
        // Returns the card holder name
        string getName();
  
        // Returns the card number
        int getNumber();
  
        // Returns the expiry month
        int getMonth();
  
        // Returns the expiry year
        int getYear();
  
        // Sets the card holder name t0 the given name
        void setName(string n);
  
        // Sets the card number to the given number
        void setNumber(int c);
  
        // Sets the expiry month to the given month
        void setMonth(int m);
  
        // Sets the expiry year to the given year
        void setYear(int y);
  };
  #endif
  </code></pre>
  
  <p>Here's the Payment.h file:</p>
  
  <pre><code>#ifndef PAYMENT_H
  #define PAYMENT_H
  
  #include &lt;string&gt;
  using namespace std;
  
  class Payment {
  
     private:
        double amount;
  
     public:
        // Creates a Payment with an amount of 0
        Payment();
  
        // Creates a Payment with the given amount
        Payment(double a);
  
        // Returns the amount
        double getAmount();
  
        // Sets the amount to the given value
        void setAmount(int a);
  
        // Creates a string out of all the Payment details
        string paymentDetails();
  };
  #endif
  </code></pre>
  
  <p>I've been up all night trying to figure this out, and I'm offically stumped. Any ideas or suggestions at all with be greatly appreciated. </p>
  
  <p>(PS: Many people on here don't seem to like using namespace std, but that's what my teacher wants)</p>