I have an assignment in which I am supposed to manage a linked list of "players" in a hockey "roster." That's not the issue... problem is, I'm trying to make the function in which a new player is added, and I can't even call it. It results in a LNK2019 error, "unresolved external error," and I have no idea where I'm going wrong. (no worries... I'm not asking you guys to complete my assignment, I just want to know why I can't call this function)
Specifically, here's what the compiler returns whenever I try to call the function:
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall roster::addPlayer(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?addPlayer@roster@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0H0@Z) referenced in function _main
1>C:\Users\Dan Visintainer\Documents\Visual Studio 2008\Projects\rosterlinkedlist2\Debug\rosterlinkedlist2.exe : fatal error LNK1120: 1 unresolved externals
Here's roster.h:
class roster
{
public:
roster(void);//CTOR
~roster(void);//DTOR
void addPlayer(std::string first, std::string last, int number, std::string position);
private:
int goals, goalsagainst;
};
Here's roster.cpp:
#include <iostream>
#include <string>
#include "roster.h"
using namespace std;
roster::roster(void)
{
roster::goals=0;
roster::goalsagainst=0;
}
roster::~roster(void)
{
}
void addPlayer(string first, string last, int number, string position)
{
cout<<"The function was called!\n";
}
And here's main.cpp:
#include <iostream>
#include <string>
#include "roster.h"
using namespace std;
void main()
{
roster mainlist;
string input, first, last, position;
int number=0, minutes=0, goals=0, goalsagainst=0;
cout<<"CSCI 201 Project 2 - Linked List\n";
while (input != "q")
{
cout<<"\nCommand? >> ";
getline(cin,input);
if (input == "ap")
{
cout<<"ADD PLAYER: Please enter the player's LAST NAME, then press ENTER:\n>> ";
getline(cin,last);
cout<<"FIRST NAME: >> ";
getline(cin,first);
cout<<"POSITION: >> ";
getline(cin,position);
cout<<"NUMBER: >> ";
cin>>number;
cout<<endl;
mainlist.addPlayer(first, last, number, position);
}
}
}
All help greatly appreciated.