Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### card.h ###
- #ifndef CARD_H_
- #define CARD_H_
- #include <vector>
- #include <string>
- #include <iostream>
- #endif
- using namespace std;
- struct Card {
- int suit, rank;
- void print () const;
- Card();
- Card(int s, int r);
- bool isGreater (const Card& c2);
- };
- vector<Card> deck (52);
- bool equals (const Card& c1, const Card& c2);
- void buildDeck();
- void printDeck(const vector<Card>& deck);
- ### card.cpp ###
- #ifndef CARD_H_
- #define CARD_H_
- #include <vector>
- #include <string>
- #include <iostream>
- #endif
- using namespace std;
- struct Card {
- int suit, rank;
- void print () const;
- Card();
- Card(int s, int r);
- bool isGreater (const Card& c2);
- };
- vector<Card> deck (52);
- bool equals (const Card& c1, const Card& c2);
- void buildDeck();
- void printDeck(const vector<Card>& deck);
- ### main.cpp ###
- #include "card.h"
- int main() {
- return 0;
- }
- ### ERROR ###
- **** Build of configuration Debug for project vector_objects ****
- make all
- Building file: ../test1/card.cpp
- Invoking: GCC C++ Compiler
- 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"
- Finished building: ../test1/card.cpp
- Building file: ../test1/main.cpp
- Invoking: GCC C++ Compiler
- 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"
- Finished building: ../test1/main.cpp
- Building target: vector_objects
- Invoking: GCC C++ Linker
- g++ -o"vector_objects" ./test1/card.o ./test1/main.o
- ./test1/main.o: In function `main':
- /usr/lib/gcc/i686-pc-linux-gnu/4.3.2/../../../../include/c++/4.3.2/new:105: multiple definition of `deck'
- ./test1/card.o:/home/johan/tdp004/workspace/vector_objects/Debug/../test1/card.cpp:48: first defined here
- collect2: ld returned 1 exit status
- make: *** [vector_objects] Error 1
Add Comment
Please, Sign In to add comment