Card and Deck: Problem linking classes (environment issues?)
<p>EDIT: I removed the main from Card.cpp, and run</p>

<pre><code>C:\cpp&gt;g++ Deck.cpp Card.cpp

C:\cpp&gt;g++ Deck.cpp Card.cpp
In file included from Deck.h:8:0,
                 from Deck.cpp:1:
Card.h: In member function 'Card&amp; Card::operator=(const Card&amp;)':
Card.h:13:12:   instantiated from 'void std::vector&lt;_Tp, _Alloc&gt;::_M_insert_aux(
std::vector&lt;_Tp, _Alloc&gt;::iterator, const _Tp&amp;) [with _Tp = Card, _Alloc = std::
allocator&lt;Card&gt;, std::vector&lt;_Tp, _Alloc&gt;::iterator = __gnu_cxx::__normal_iterat
or&lt;Card*, std::vector&lt;Card&gt; &gt;, typename std::vector&lt;_Tp, _Alloc&gt;::_Base::_Tp_all
oc_type::pointer = Card*]'
c:\mingw\bin\../lib/gcc/mingw32/4.5.0/include/c++/bits/stl_vector.h:749:4:   ins
tantiated from 'void std::vector&lt;_Tp, _Alloc&gt;::push_back(const value_type&amp;) [wit
h _Tp = Card, _Alloc = std::allocator&lt;Card&gt;, value_type = Card]'
Deck.cpp:7:44:   instantiated from here
Card.h:13:12: error: non-static const member 'const int Card::rank', can't use d
efault assignment operator
Card.h:13:12: error: non-static const member 'const Suit Card::suit', can't use
default assignment operator
In file included from c:\mingw\bin\../lib/gcc/mingw32/4.5.0/include/c++/vector:6
9:0,
                 from Deck.h:4,
                 from Deck.cpp:1:
c:\mingw\bin\../lib/gcc/mingw32/4.5.0/include/c++/bits/vector.tcc: In member fun
ction 'void std::vector&lt;_Tp, _Alloc&gt;::_M_insert_aux(std::vector&lt;_Tp, _Alloc&gt;::it
erator, const _Tp&amp;) [with _Tp = Card, _Alloc = std::allocator&lt;Card&gt;, std::vector
&lt;_Tp, _Alloc&gt;::iterator = __gnu_cxx::__normal_iterator&lt;Card*, std::vector&lt;Card&gt;
&gt;, typename std::vector&lt;_Tp, _Alloc&gt;::_Base::_Tp_alloc_type::pointer = Card*]':
c:\mingw\bin\../lib/gcc/mingw32/4.5.0/include/c++/bits/vector.tcc:312:4: note: s
ynthesized method 'Card&amp; Card::operator=(const Card&amp;)' first required here
</code></pre>

<p>I don't know what the problem is. Someone else tells me that it compiled perfectly fine on their computer.   Anybody know what's going on?</p>

<p>Card.h</p>

<pre><code>#ifndef CARD_H
#define CARD_H

#include &lt;string&gt;

enum Suit {
            SUIT_HEART,
            SUIT_DIAMOND,
            SUIT_CLUB,
            SUIT_SPADE
        };


class Card {
    private:
        const int rank;
        const Suit suit;
        static const char * ranknames[];
        static const char * suitnames[];
    public:
        Card(int r = 1, Suit s = SUIT_HEART) : rank(r), suit(s)
            {
            }

        int GetRank() const { return rank; };
        Suit GetSuit() const { return suit; }
        std::string ToString() const;
        std::string SuitString() const;
        std::string RankString() const;
};
#endif
</code></pre>

<p>Card.cpp</p>

<pre><code>#include &lt;iostream&gt;
#include "Card.h"
#include &lt;vector&gt; 

const char * Card::ranknames[] = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" };
const char * Card::suitnames[] = { "Hearts", "Diamonds", "Clubs", "Spaces" };

std::string Card::ToString() const {
    std::string s = RankString();
    s.append(" of ");
    s.append(SuitString());
    return s;
}

std::string Card::SuitString() const {
    return suitnames[suit];
}

std::string Card::RankString() const {
    return ranknames[rank-1];
}
</code></pre>

<p>Deck.h</p>

<pre><code>#ifndef DECK_H
#define DECK_H

#include &lt;vector&gt;
#include &lt;string&gt;
#include &lt;algorithm&gt;
#include &lt;iostream&gt;
#include "Card.h"
#endif
</code></pre>

<p>Deck.cpp</p>

<pre><code>#include "Deck.h"

int main() {
    std::vector&lt;Card&gt; Deck;

        for (int i = 0; i &lt; 10 ; i++) {
            Deck.push_back(Card(i+1,(Suit)((i+1)%4)));
            std::cout &lt;&lt; Deck[i].ToString() &lt;&lt; std::endl;
        }

}
</code></pre>
