Guest User

Untitled

a guest
May 25th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. ### card.h ###
  2. #ifndef CARD_H_
  3. #define CARD_H_
  4. #include <vector>
  5. #include <string>
  6. #include <iostream>
  7. #endif
  8.  
  9. using namespace std;
  10.  
  11.  
  12. struct Card {
  13. int suit, rank;
  14. void print () const;
  15. Card();
  16. Card(int s, int r);
  17. bool isGreater (const Card& c2);
  18. };
  19.  
  20. vector<Card> deck (52);
  21.  
  22. bool equals (const Card& c1, const Card& c2);
  23. void buildDeck();
  24. void printDeck(const vector<Card>& deck);
  25.  
  26. ### card.cpp ###
  27. #ifndef CARD_H_
  28. #define CARD_H_
  29. #include <vector>
  30. #include <string>
  31. #include <iostream>
  32. #endif
  33.  
  34. using namespace std;
  35.  
  36.  
  37. struct Card {
  38. int suit, rank;
  39. void print () const;
  40. Card();
  41. Card(int s, int r);
  42. bool isGreater (const Card& c2);
  43. };
  44.  
  45. vector<Card> deck (52);
  46.  
  47. bool equals (const Card& c1, const Card& c2);
  48. void buildDeck();
  49. void printDeck(const vector<Card>& deck);
  50.  
  51. ### main.cpp ###
  52. #include "card.h"
  53.  
  54. int main() {
  55. return 0;
  56. }
  57.  
  58. ### ERROR ###
  59.  
  60. **** Build of configuration Debug for project vector_objects ****
  61.  
  62. make all
  63. Building file: ../test1/card.cpp
  64. Invoking: GCC C++ Compiler
  65. g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"test1/card.d" -MT"test1/card.d" -o"test1/card.o" "../test1/card.cpp"
  66. Finished building: ../test1/card.cpp
  67.  
  68. Building file: ../test1/main.cpp
  69. Invoking: GCC C++ Compiler
  70. g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"test1/main.d" -MT"test1/main.d" -o"test1/main.o" "../test1/main.cpp"
  71. Finished building: ../test1/main.cpp
  72.  
  73. Building target: vector_objects
  74. Invoking: GCC C++ Linker
  75. g++ -o"vector_objects" ./test1/card.o ./test1/main.o
  76. ./test1/main.o: In function `main':
  77. /usr/lib/gcc/i686-pc-linux-gnu/4.3.2/../../../../include/c++/4.3.2/new:105: multiple definition of `deck'
  78. ./test1/card.o:/home/johan/tdp004/workspace/vector_objects/Debug/../test1/card.cpp:48: first defined here
  79. collect2: ld returned 1 exit status
  80. make: *** [vector_objects] Error 1
Add Comment
Please, Sign In to add comment