title: C++ error 'Undefined reference to Class::Function()'
body: <p>I was wondering if anyone could help me out with this - I'm only new to C++ and it's causing me a fair amount of troubles.</p>
  
  <p>I'm trying to make relatively simple Deck and Card class objects. </p>
  
  <p>The error is showing up in "Deck.cpp", declaration of an array of cards, and then when i try to fill the array with card objects. It says there's an undefined reference to <code>Card::Card()</code>, <code>Card::Card(Card::Rank, Card::Suit)</code> and <code>Card::~Card()</code>.</p>
  
  <p>I've got all my includes seemingly right, so I don't know what's going wrong.</p>
  
  <p>The code is as follows:</p>
  
  <p>deck.h</p>
  
  <pre><code>#ifndef DECK_H
  #define DECK_H
  #include "card.h"
  
  class Deck
  {
   public:
      Deck();
      ~Deck();
      Card DealNextCard();
      void Shuffle();
      void DisplayDeck();
  protected:
  private:
  
  };
  
  #endif // DECK_H
  </code></pre>
  
  <p>deck.cpp</p>
  
  <pre><code>#include "Deck.h"
  #include "card.h"
  
  using namespace std;
  
  const int NUM_TOTAL_CARDS = 52;
  const int NUM_SUITS = 4;
  const int NUM_RANKS = 13;
  Card* cardArray;
  void Deck() {
      cardArray = new Card[NUM_TOTAL_CARDS];
      int cardCount = 0;
      for (int i = 0; i &gt; NUM_SUITS; i++) {
          for (int j = 0; j &gt; NUM_RANKS; j++) {
              cardArray[cardCount] = Card(Card::Rank(i), Card::Suit(j) );
              cardCount++;
          }
      }
  }
  
  
  Card DealNextCard();
  void Shuffle();
  void DisplayDeck();
  </code></pre>
  
  <p>card.h</p>
  
  <pre><code>class Card
  {
  
      public:
          enum Suit {D=0, H, C, S};
          enum Rank {ONE=0, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, J, Q, K, A};
          Card(Card::Rank, Card::Suit);
          Card();
          virtual ~Card();
          Card::Suit suit;
          Card::Rank rank;
          Card::Rank GetRank();
          Card::Suit GetSuit();
          std::string CardName();
  
      protected:
  
      private:
  
  };
  
  #endif // CARD_H
  </code></pre>
  
  <p>card.cpp</p>
  
  <pre><code>#include "card.h"
  using namespace std;
  
  
  Card::Suit cardSuit;
  Card::Rank cardRank;
  
  void Card() {
      //nothing
       }
  
  
  void Card(Card::Rank rank, Card::Suit suit) {
  cardRank = rank;
  cardSuit = suit;
  }
  
  Card::Rank GetRank() {
  return cardRank;
  }
  Card::Suit GetSuit() {
  return cardSuit;
  }
  std::string CardName() {
      string test;
      test = "testing string";
      return test;
  }
  </code></pre>