title: So I am practicing inheritance for my school Assignment but I am not being able to properly implement the header guards
body: <p>I have a base class card with basic card attributes. In main I get an error of redefinition as the class CallingCard and the IDCard both are inheriting the base class Card. I have tried using header guards but I am not being able to properly implement them. Also in main while using a G++ compiler, I need to include ".cpp" instead of ".h" as including ".h" gives me an error </p>
  
  <p>Undefined symbols for architecture x86_64:</p>
  
  <p>_main in main-ad117f.o
    (int, std::__1::basic_string, std::__1::allocator >, std::__1::basic_string, std::__1::allo
  cator >, int, std::__1::basic_string, std::__1::allocator >, int)", referenced from:</p>
  
  <p>_main in main-ad117f.o</p>
  
  <p>ld: symbol(s) not found for architecture x86_64</p>
  
  <p>clang: error: linker command failed with exit code 1 (use -v to see invocation)</p>
  
  <p>It could not be header guards and could be the inclusion of ".cpp" instead of ".h" in main but that gives me an error I don't know how to fix
  Please help me out to fix whatever the problem is, be it header guards or including ".cpp" instead of ".h"</p>
  
  <p>Card.h</p>
  
  <p>This is my base class</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;string.h&gt;
  using namespace std;
  #ifndef CARD_H           //Header guards or pragma once? and how to implement?
  #define CARD_H
  class Card
  {
      private:
      int cardNumber;
      protected:
      string ownerName;
      public:
      string expiryDate;
      Card(int cardNumber=0, string ownerName="Non", string expiryDate="0");
      void display();
  };
  #endif
  </code></pre>
  
  <p>Card.cpp</p>
  
  <pre><code>#include"Card.h"
  Card::Card(int cardNumber, string ownerName, string expiryDate)
  {
      this-&gt;cardNumber=cardNumber;
      this-&gt;ownerName=ownerName;
      this-&gt;expiryDate=expiryDate;
  }
  
  void Card::display()
  {
      cout&lt;&lt;"Card Number: "&lt;&lt;this-&gt;cardNumber&lt;&lt;endl;
      cout&lt;&lt;"Owner Name: "&lt;&lt;this-&gt;ownerName&lt;&lt;endl;
      cout&lt;&lt;"Expiry Date: "&lt;&lt;this-&gt;expiryDate&lt;&lt;endl;
  }
  </code></pre>
  
  <p>CallingCard.h</p>
  
  <p>This is a child class inheriting from base class</p>
  
  <pre><code>#include"Card.cpp"
  #ifndef CALLINGCARD_H
  #define CALLINGCARD_H
  class CallingCard :
          public Card
  {
      private:
      int amount;
      string companyName;
      int PIN;
      public:
      CallingCard(int cardNumber, string ownerName, string expiryDate, int amount=0, string companyName="Non", int PIN=0);
      void display();
  
  };
  #endif
  </code></pre>
  
  <p>CallingCard.cpp</p>
  
  <pre><code>#include"CallingCard.h"
  CallingCard::CallingCard(int cardNumber, string ownerName, string expiryDate, int amount, string companyName, int PIN):Card(cardNumber,ownerName,expiryDate)
  {
      this-&gt;amount=amount;
      this-&gt;companyName=companyName;
      this-&gt;PIN=PIN;
  }
  
  void CallingCard::display()
  {
      Card::display();
      cout&lt;&lt;"Amount: "&lt;&lt;this-&gt;amount&lt;&lt;endl;
      cout&lt;&lt;"Company Name: "&lt;&lt;this-&gt;companyName&lt;&lt;endl;
      cout&lt;&lt;"PIN: "&lt;&lt;this-&gt;PIN&lt;&lt;endl;
  }
  </code></pre>
  
  <p>IDCard.h</p>
  
  <p>This is a another child class inheriting from base class</p>
  
  <pre><code>#include"Card.cpp"
  #ifndef IDCARD_H
  #define IDCARD_H
  class IDCard :
          protected Card
  {
      private:
      int CNICNumber;
      int age;
      public:
      IDCard(int cardNumber, string ownerName, string expiryDate, int CNICNumber=0, int age=0);
      string getExpiryDate() const;
      void display();
  
  };
  #endif
  </code></pre>
  
  <p>IDCard.cpp</p>
  
  <pre><code>#include"IDCard.h"
  IDCard::IDCard(int cardNumber, string ownerName, string expiryDate, int CNICNumber, int age):Card(cardNumber,ownerName,expiryDate)
  {
      this-&gt;CNICNumber=CNICNumber;
      this-&gt;age=age;
  }
  void IDCard::display()
  {
      Card::display();
      cout&lt;&lt;"CNIC Number: "&lt;&lt;this-&gt;CNICNumber&lt;&lt;endl;
      cout&lt;&lt;"Age: "&lt;&lt;this-&gt;age&lt;&lt;endl;
  }
  </code></pre>
  
  <p>Main.cpp</p>
  
  <pre><code>#include"CallingCard.cpp"
  #include"IDCard.cpp"
  int main()
  {
      CallingCard card(1234, "Sana", "10-2-2018", 1000, "Warid", 444);
      card.display();
  
  
      IDCard idCard(1234, "Sana", "10-2-2018", 35202, 29);
      idCard.display();
  
  
  
  }
  </code></pre>