Problem with link
Sep 8, 2009 at 2:43am UTC
I'm trying to work with Link Lists and I keep getting a link error when I try and create an instance of the class. I've been working on figuring out this problem for the better part of the weekend. I've seen solutions on downloading an SDK and adding some linkers, but non of those have worked. Thanks in advance.
The problem is when I declare this:
BlackJack BJ;
Here are the errors:
Error 1 error LNK2019: unresolved external symbol "public: __thiscall BlackJack::~BlackJack(void)" (??1BlackJack@@QAE@XZ) referenced in function _main Main.obj BlackJackClass
Error 2 fatal error LNK1120: 1 unresolved externals C:\Documents and Settings\Desktop\BlackJackClass\Debug\BlackJackClass.exe 1 BlackJackClass
Here is my header file:
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
#ifndef BLACKJACK_H
#define BLACKJACK_H
#include <iostream>
#include <iomanip>
#include <string>
#include <ctime>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <fstream>
class BlackJack
{
private :
struct Cards
{
std::string Faces;
std::string Suits;
int intCardValues;
struct Cards *next;
};
Cards *head;
public :
//Constructor
BlackJack()
{head = NULL;}
//Destructor
~BlackJack();
//Operations
void AddCards(std::string, std::string, int );
void DeleteCards(std::string, std::string, int );
void DisplayCards() const ;
};
#endif
My cpp file for the header:
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
#include "BlackJack.h"
void BlackJack::AddCards(std::string f, std::string s, int v)
{
Cards *NewCard;
Cards *CardPtr;
NewCard = new Cards;
NewCard->Faces = f;
NewCard->Suits = s;
NewCard->intCardValues = v;
NewCard->next = NULL;
if (!head)
head = NewCard;
else
{
CardPtr = head;
while (CardPtr->next)
CardPtr = CardPtr->next;
CardPtr->next = NewCard;
}
}
any my main.cpp:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#include "BlackJack.h"
void main()
{
BlackJack BJ;
int const intCards = 20;
std::vector<int > Cards;
srand(int (time(0)));
//Suits
std::string CSuits[] = {"Clubs" , "Spades" , "Diamonds" , "Hearts" };
//Faces
std::string CFaces[] = {"Ace" , "Jack" , "King" , "Queen" , "Two" , "Three" ,
"Four" , "Five" , "Six" , "Seven" , "Eight" , "Nine" };
for (int intIndex = 0; intIndex < intCards; intIndex++)
Cards.push_back(intIndex);
system ("pause" );
}
Sep 8, 2009 at 4:48am UTC
Okay, do this. What's on line 33 of blackjack.h? Spoiler: rotcurtsed s'kcaJkcalB fo noitaralced ehT
Now, point to the definition for me.
Topic archived. No new replies allowed.