The title may be a little misleading, as I have the stack template working just fine. I can't for the life of me figure out why I'm getting an unresolved link error in my implementation of it though. I know this code isn't complete as the pop function I've written isn't going to work right, but I'm getting the error when I compile and typically it would mean I mispelled something or didn't include a header file or something but it's all there and spelled correctly. Can someone take a look at this and please tell me what I'm missing? Why am I getting a LNK2019 error from the compiler in reference to the pushItem and popItem functions?
#include <iostream>
#include <string>
#include "DynamicStack.h"
#include "InventoryBin.h"
usingnamespace std;
void popItem(DynamicStack<InventoryBin>* inventory);
void pushItem(DynamicStack<InventoryBin>* inventory);
int menu();
int main()
{
DynamicStack<InventoryBin> *inventory = new DynamicStack<InventoryBin>;
int menuchoice;
cout <<"Welcome to Brian's inventory tracker v0.01B\n";
do
{
menuchoice = menu();
switch (menuchoice)
{
case 1: pushItem(inventory);
break;
case 2: popItem(inventory);
break;
}
}
while (menu() != 3);
return 0;
}
void popItem(DynamicStack<InventoryBin> inventory)
{
InventoryBin item;
inventory.pop(item);
}
void pushItem(DynamicStack<InventoryBin> inventory)
{
int userint;
string userstring;
InventoryBin item;
cout <<"Please enter the item's serial number:\n";
cin >> userint;
item.setSerialNum(userint);
cout <<"Please enter the date of manufacture:\n";
cin >> userstring;
item.setManufactDate(userstring);
cout <<"Please enter the lot number of the item:\n";
cin >> userint;
item.setLotNum(userint);
inventory.push(item);
}
int menu()
{
int userchoice;
cout <<"Please make a selection from the menu\n";
cout <<"1 - Add an item to the inventory\n";
cout <<"2 - Remove an item from the inventory\n";
cout <<"3 - Quit\n";
cin >> userchoice;
return userchoice;
}
No I figured it out. I'm an idiot. I declared the funtions in question to accept a pointer but when I defined them I sent them instances of objects not pointers to the object. Doh!