I'm getting the following error and I don't know how to fix it:
Error 1 error LNK2001: unresolved external symbol "public: static int HotDogStand::DogCounter" (?DogCounter@HotDogStand@@2HA) CartTesting.obj CartTesting
I'm trying to use the HotDogStand::JustSold() function to increment the DogCounter variable by 1, or none (depending on user entry). I think my error may lie in the fact that I don't know how to properly import the DogCounter...
#include <iostream>
#include <fstream>
using namespace std;
class HotDogStand
{
public:
void JustSold();
int Cart;
int IdNumber;
int SalesToday;
int TotalSales;
int IncrementalSale;
static int DogCounter;
};
int main()
{
int numCarts;
static int DogCounter;
HotDogStand HotDogSales;
cout << "Please Enter The Number of Carts: ";
cin >> numCarts;
HotDogStand * CartSales = new HotDogStand[numCarts];
DogCounter = 0;
for(int x=0; x<numCarts; x++)
{
cout << "ID of Cart #" << x+1 << ": ";
cin >> CartSales[x].Cart;
for (int y=1;y<numCarts; y++)
{
cout << "How many Hot Dogs Did Cart # " << CartSales[x].Cart << " sell?"
<< endl;
cin >> CartSales[y].Cart;
DogCounter += CartSales[y].Cart;
}
}
cout << endl;
cout << "Total Hot Dogs Sold Thus Far = " << DogCounter << endl;
cout << endl;
HotDogSales.JustSold();
return 0;
}
void HotDogStand::JustSold()
{
int Answer;
int JustSoldCounter;
cout << "Did Your Carts Sell a Hot Dog?" << endl;
cout << "Enter 1 for Yes, or 2 for No" << endl;
cin >> Answer;
JustSoldCounter = 0;
if (Answer == 1)
{
JustSoldCounter += 1;
DogCounter ++ ;
cout << JustSoldCounter;
}
else if (Answer == 2)
{
JustSoldCounter += 0;
cout << JustSoldCounter;
}
else
cout << "Error!" << endl;
}