I am trying to code a game of Black Jack for a class and we need to use header files and multiple .cpp files. I have the code figured out but I am having trouble calling the functions within my main function. The code is posted below. It is all in the same folder so I don't think that is the problem. I am trying to learn how to call any of these functions within my main (BlackJackMike.cpp). The error I keep getting is
"LNK2019 unresolved external symbol "public: int __thiscall Card::getcValue(void)const " (?getcValue@Card@@QBEHXZ) referenced in function _main BlackJackMike C:\Users\merisman96\source\repos\BlackJackMike\BlackJackMike\BlackJackMike.obj"
I have searched around but still cant fix this error. Any help would be great!!! Thanks!!!
O and also I am using Visual Studio 2017 I don't know if that means anything.
BlackJackMike.cpp where my main is at
#include "stdafx.h"
//#include "Deck.h"
#include "Card.h"
using namespace std;
int main()
{
Card C; //not to sure what happens here but I know I need it
C.getcValue(); //Attempting to call the function getcValue() from my card class
return 0;
}
Card.h
#pragma once
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <sstream>
#include <string>
#include <limits>
#include <random>
using namespace std;
class Card {
char card;
int cValue;
int cSuite;
string cSName;
bool isCardMade;
public:
Card() {};
Card(char, int);
//Card(const Card&);
int assignCV();
int getcValue()const;
int getCSuite()const;
string getCName()const;
bool getIsCardMade()const;
char getCard()const;
void setIsCardMade(bool x);
void nameCard();
};
Card.cpp
#include "Card.h"
Card::Card(char Value, int suite)
{
card = Value;
cValue = assignCV();
cSuite = suite;
isCardMade = false;
}
//Card::Card(const Card & card1)
//{
// card = card1.getCard();
// cValue = card1.getcValue();
// cSuite = card1.getCSuite();
// cSName = card1.getCName();
// isCardMade = card1.getIsCardMade();
//}
int Card::assignCV()
{
if (card == 'A')
return 11;
else if (card == 'T' || card == 'J' || card == 'Q' || card == 'K') // here we see 'T' as 10 being assigned the value of 10
return 10;
else
return (card - '0');
}
int Card::getcValue() const
{
cout << "Ran getcValue" << endl;
return cValue;
}
int Card::getCSuite() const
{
return cSuite;
}
string Card::getCName() const
{
return cSName;
}
bool Card::getIsCardMade() const
{
return isCardMade;
}
char Card::getCard() const
{
return card;
}
void Card::setIsCardMade(bool x)
{
isCardMade = x;
}
void Card::nameCard()
{
switch (cSuite) {
case 0: cSName = "Spades";
break;
case 1: cSName = "Clubs";
break;
case 2: cSName = "Hearts";
break;
case 3: cSName = " Diamonds";
break;
}
if (card == 'A')
cout << "Ace";
else if (card == 'J')
cout << "Jack";
else if (card == 'Q')
cout << "Queen";
else if (card == 'K')
cout << "king";
else if (card == 'T') // We see that once again the 10 is stored as a 'T'
cout << "10"; // and that it is being printed as '10'
else
cout << cValue;
cout << " of " << cSName << endl;
}