Error Undefined Reference To
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack linker error undefined reference to Overflow the company Business Learn more about hiring developers or posting ads with us
Error Undefined Reference To 'typeinfo For
Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community error undefined reference to 'vtable for of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Linker Error C++ “undefined reference ” [duplicate] up vote 9 down vote favorite 2 Possible Duplicate:
Error Undefined Reference To Winmain@16'
What is an undefined reference/unresolved external symbol error and how do I fix it? Trying to compile my program via g++ -o prog1 main.cpp -std=c++0x I get the error: /tmp/cc1pZ8OM.o: In function `main': main.cpp:(.text+0x148): undefined reference to `Hash::insert(int, char)' collect2: error: ld returned 1 exit status main.cpp #include
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about
Error Undefined Reference To '__atomic_fetch_add_4'
Stack Overflow the company Business Learn more about hiring developers or posting ads with
Error Undefined Reference To '__swbuf'
us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is error undefined reference to pthread_create' a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up C++ error 'Undefined reference to Class::Function()' [duplicate] up vote 20 down vote favorite 3 http://stackoverflow.com/questions/14557657/linker-error-c-undefined-reference This question already has an answer here: What is an undefined reference/unresolved external symbol error and how do I fix it? 25 answers 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. I'm trying to make relatively simple Deck and Card class objects. The error is showing up in "Deck.cpp", declaration of an http://stackoverflow.com/questions/15712821/c-error-undefined-reference-to-classfunction array of cards, and then when i try to fill the array with card objects. It says there's an undefined reference to Card::Card(), Card::Card(Card::Rank, Card::Suit) and Card::~Card(). I've got all my includes seemingly right, so I don't know what's going wrong. The code is as follows: deck.h #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 deck.cpp #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 > NUM_SUITS; i++) { for (int j = 0; j > NUM_RANKS; j++) { cardArray[cardCount] = Card(Card::Rank(i), Card::Suit(j) ); cardCount++; } } } Card DealNextCard(); void Shuffle(); void DisplayDeck(); card.h 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 card.cpp #include "card.h" using namespace std; Card::Suit cardSuit; Card::Rank cardRank; void Card() { //nothing } void Card(Card::Rank rank
tried to compile it and I got this error: Undefined reference to 'intro()' Undefined reference to 'menu(int' I looked into the code and I can't find any obvious errors, so I googled around and didn't find anything error undefined that would fix my error... Here's my code: Main.cpp 1
2
3
4
5
6
7
8
9
#include "headers.h" int main() { intro(); menu(0); } headers.h 1
2
3
4
5
6
7
8
9
10
11
12
13
14
//all the #includes: #include
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include "headers.h" //intro function:: pretty simpple stuff: void intro() { cout << endl; cout << endl; cout << endl; cout << endl; cout << " A Game By Mrcerimo" << endl; Sleep(1500); cout << " The Match the pairs game" << endl; Sleep(1500); } //menu function: //it contains two kind of menus: //1.menu is the menu that you get in when you strat the program //2. menu is the menu you can accsess while playing the game , thus the option to continue:: void menu(int x) // takes in int x, so we will know wich menu to choose: { if