compiling errors with no hints..

I got the compiling errors with no hints which are LNK2005 and LNK1169. I have no idea what that is. Please help!

card.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <cstring>
using namespace std;

class Card
{
private:
   int face;
   int suit;
 
public:
   Card(int f, int s);
   static string faces[13];
   static string suits[4];
   string toString();
}; 



card.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <cstring>
#include "Card.h"
using namespace std;

Card::Card(int f, int s)
{
  face = f;
  suit = s;
}

string Card::suits[4] = { "DIAMONDS", "CLUBS", "HEARTS", "SPADES" };
string Card::faces[13] = { "ACE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE",
"TEN", "JACK", "QUEEN", "KING" };

string Card::toString()
{
  return faces[face] + " of " + suits[suit];
}


DeckOfCards.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <vector>
#include "Card.h"

class DeckOfCards
{

private:
  vector<Card> deck;
  int currentCard;
  int A[52];

public:
  DeckOfCards();
  void Shuffle();
  Card dealCards();
  bool moreCards();
}; 


DeckOfCards.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
#include <vector>
#include <cstdlib>
#include "DeckOfCards.h"

DeckOfCards::DeckOfCards()
{
  currentCard = 0;
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      Card c = Card(i, j);
      deck.push_back(c);
    }
  }
  for (int i = 0; i < 52; i++)
    A[i] = 0;
}

void DeckOfCards::Shuffle()
{
  for (int i = 0; i < 52; i++) {
    Card tmp = deck[i];
    int r;
    while (true) {
      r = rand() % 52;
      if (A[r] == 0)
        break;
    }
    deck[i] = deck[r];
    deck[r] = deck[i];
    A[r] = 1;
  }
}

Card DeckOfCards::dealCards()
{
  return deck[currentCard++];
}

bool DeckOfCards::moreCards()
{
  if (currentCard < 51) {
    return true;
  }

  else {
    return false;
  }
}



main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <string>
#include <ctime>
#include <cstdlib>
#include "DeckOfCards.cpp"
using namespace std;

int main()
{
  DeckOfCards D;
  int count = 1;
  D.Shuffle();

  while (D.moreCards() == true) {
    cout << D.dealCards().toString() << endl;
  }

	system("PAUSE");
	return 0;
}

Last edited on
http://www.cplusplus.com/forum/articles/40071/#msg216270
if it just says «LNK2005» throw acid on that compiler.
Also, show your build command.

and if you could upload your code to github, or upload a zip, so we don't have to replicate your file structure, that would help a lot


some common things that may be
undefined reference: http://www.cplusplus.com/forum/general/113904/
multiple definition: http://www.cplusplus.com/forum/general/140198/

> #include "DeckOfCards.cpp"
that shouldn't be there. don't include *.cpp
you should include only the header (the .h)
Topic archived. No new replies allowed.