0

I am receiving the following error messages and I can't figure out why, I'm guessing there's just some syntax rule or something I am just unaware of... there errors are:

error LNK2019: unresolved external symbol "void __cdecl validateWidgets(int &)" (?validateWidgets@@YAXAAH@Z) referenced in function "void __cdecl manager(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?manager@@YAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

and

error LNK2019: unresolved external symbol "void __cdecl getInfo(int,double &,int &)" (?getInfo@@YAXHAANAAH@Z) referenced in function "void __cdecl tempWorker(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?tempWorker@@YAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

here's my code:

#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

void getInfo(int, double &, int &);
string getName();
void heading(string);
char menu(string);
void evaluateChoice(char, string);
void validateHours(double &);
void validateHours(int &);
void validateWidgets(int &);
void validateEmployees(int &);
void manager(string);
void tempWorker(string);
void ftWorker(string);
char addEmployee();
char restartApp();

int main() 
{
	char restart;
	char moreEmployees;
	do
	{
		string userName;
		userName = getName();
		do
		{
			heading(userName);
			char menuChoice = menu(userName);
			evaluateChoice(menuChoice, userName);
			moreEmployees = addEmployee();
		}while (moreEmployees == 'y' || moreEmployees == 'Y');
		restart = restartApp();
	}while (restart == 'y');
	return 0;
}

void validateWidget(int &widgets)
{
	if(widgets < 0 || widgets > 500)
	{
		do
		{
			cout << "Invalid input. Please enter a positive number of no more than 500: ";
			cin >> widgets;			
		} while(widgets < 0 || widgets > 500);
	}
}
void validateHours(double &hours)
{
		if(hours < 0 || hours > 60)
	{
		do
		{
			cout << "Invalid input. Please enter a positive number of no more than 60: ";
			cin >> hours;			
		} while(hours < 0 || hours > 60);
	}
}
void validateHours(int &hours)
{
		if(hours < 0 || hours > 60)
	{
		do
		{
			cout << "Invalid input. Please enter a positive number of no more than 60: ";
			cin >> hours;			
		} while(hours < 0 || hours > 60);
	}
}
void validateEmployees(int &numEmployees)
{
		if( numEmployees < 0 || numEmployees > 60)
	{
		do
		{
			cout << "Invalid input. Please enter a number 1-4: ";
			cin >> numEmployees;			
		} while(numEmployees < 0 || numEmployees > 60);
	}
}
void getInfo(int numEmployees, double &hours, double &totalWidgets)
{
	double tempHours, tempWidgets;
	for(int count = numEmployees; count > 0; count--)
	{
		cout << "Enter the number of hours worked: ";
		cin >> tempHours;
		hours += tempHours;
		cout << "Enter the number of widgets sold: ";
		cin >> tempWidgets;
		totalWidgets += tempWidgets;
	}
}
char addEmployee()
{
	char choice;
	cout << "Data for another employee? Y/N ";
	cin >> choice;
	while(choice != 'y' && choice != 'Y' && choice != 'n' && choice != 'N')
	{
		cout << "Invalid. Enter only Y or N. Another employee? Y/N ";
		cin >> choice;
	}
	return choice;
	
}


string getName() 
{
	char name[31];
	cout << "What is your name? ";
	cin.getline(name, 31);
	return name;
}

void heading(string userName)
{
	cout << endl << setw(35) << "Welcome to ASU Widget Shop\n" << setw(30) << "at the Tempe Campus\n";
}

char menu(string userName)
{
	char choice;
	cout << endl << setw(20) << userName << ", please choose" << endl << setw(34) << "the category for data entry.";
	cout << endl << endl << setw(28) << "A.\ta temporary employee";
	cout << endl << setw(28) << "B.\ta full-time employee";
	cout << endl << setw(17) << "C.\ta manager";
	cout << endl << "Enter a letter: ";
	cin >> choice;
	return choice;
}

void evaluateChoice(char menuChoice, string userName)
{
	do
	{
		switch (menuChoice)
		{
		case 'a':
		case 'A':
			tempWorker(userName);
			break;
		case 'b':
		case 'B':
			ftWorker(userName);
			break;
		case 'c':
		case 'C':
			manager(userName);
			break;
		default:
			cout << "Invalid entry. Please enter A, B, or C: ";
			cin >> menuChoice;
		}
	}while(menuChoice != 'A' && menuChoice != 'a' && menuChoice != 'B' && menuChoice != 'b' && menuChoice != 'C' && menuChoice != 'c');
}
void manager(string userName)
{
	const double wage = 12.00;
	const double widgetBonus = 0.02;
	const double vacationRate = 0.30;
	const double sickRate = 0.20;
	double hours;
	int widgets, totalWidgets;
	cout << "There is only one manager. Enter the number of hours worked: ";
	cin >> hours;
	validateHours(hours);
	cout << "\nNumber of widgets sold by the temp worker: ";
	cin >> widgets;
	validateWidgets(widgets);
	totalWidgets = widgets;
	cout << "\nNumber of widgets sold by the FT worker: ";
	cin >> widgets;
	validateWidgets(widgets);
	totalWidgets += widgets;
	double basePay = wage * hours;
	double widgetPay = totalWidgets * widgetBonus;
	double totalPay = widgetPay + basePay;
	double vacationDays = hours / 40 * vacationRate;
	double sickDays = hours / 40 * sickRate;
	cout << endl << endl << setw(50) << "Salary data for the ASU Widget Shop";
	cout << endl << setw(50) << "by " << userName << endl << endl;
	cout << setw(50) << "hours\tbase\twidgets\ttotal\tvac.\tsick";
	cout << endl << setw(43) << "average for\tworked\tpay\tsold\tpay\tdays\tdays";
	cout << endl << fixed << setprecision(2) << setw(50) << "manager\t" << hours << "\t"
		<< basePay << "\t" << totalWidgets << "\t" << totalPay << "\t" << vacationDays
		<< "\t" << sickDays;
}
void tempWorker(string userName)
{
	const double wage = 8.55;
	const double widgetBonus = 0.05;
	const double vacationRate = 0.00;
	const double sickRate = 0.00;
	double hours = 0.00;
	int numEmployees;
	int totalWidgets = 0;
	cout << "How many temps are there? (1-4) ";
	cin >> numEmployees;
	validateEmployees(numEmployees);
	getInfo(numEmployees, hours, totalWidgets);
	double basePay = wage * hours / numEmployees; // Calculates the average base pay
	int widgetsSold = totalWidgets / numEmployees; // Calculates the average number of widgets sold
	double widgetPay = widgetsSold * widgetBonus; // Calculates the bonus pay from widget sales
	double totalPay = widgetPay + basePay; // Calculates the total pay including widget bonus
	double vacationDays = hours / 40 * vacationRate; // Calculates vacation days
	double sickDays = hours / 40 * sickRate; // Calculates sick days
	cout << endl << endl << setw(50) << "Salary data for the ASU Widget Shop";
	cout << endl << setw(50) << "by " << userName << endl << endl;
	cout << setw(50) << "hours\tbase\twidgets\ttotal\tvac.\tsick";
	cout << endl << setw(43) << "average for\tworked\tpay\tsold\tpay\tdays\tdays";
	cout << endl << fixed << setprecision(2) << setw(50) << "manager\t" << hours << "\t"
		<< basePay << "\t" << totalWidgets << "\t" << totalPay << "\t" << vacationDays
		<< "\t" << sickDays;
}

void ftWorker(string userName)
{
	const double wage = 8.55;
	const double widgetBonus = 0.05;
	const double vacationRate = 0.25;
	const double sickRate = 0.20;
		double hours = 0.00;
	int numEmployees;
	int totalWidgets = 0;
	cout << "How many FT employees? (1-4) ";
	cin >> numEmployees;
	validateEmployees(numEmployees);
	getInfo(numEmployees, hours, totalWidgets);
	double basePay = wage * hours / numEmployees; // Calculates the average base pay
	int widgetsSold = totalWidgets / numEmployees; // Calculates the average number of widgets sold
	double widgetPay = widgetsSold * widgetBonus; // Calculates the bonus pay from widget sales
	double totalPay = widgetPay + basePay; // Calculates the total pay including widget bonus
	double vacationDays = hours / 40 * vacationRate; // Calculates vacation days
	double sickDays = hours / 40 * sickRate; // Calculates sick days
	cout << endl << endl << setw(50) << "Salary data for the ASU Widget Shop";
	cout << endl << setw(50) << "by " << userName << endl << endl;
	cout << setw(50) << "hours\tbase\twidgets\ttotal\tvac.\tsick";
	cout << endl << setw(43) << "average for\tworked\tpay\tsold\tpay\tdays\tdays";
	cout << endl << fixed << setprecision(2) << setw(50) << "manager\t" << hours << "\t"
		<< basePay << "\t" << totalWidgets << "\t" << totalPay << "\t" << vacationDays
		<< "\t" << sickDays;
}
char restartApp()
{
	char choice;
	cout << "Do you want to begin again? Y/N ";
	cin >> choice;
	while(choice != 'y' && choice != 'Y' && choice != 'n' && choice != 'N')
	{
		cout << "Invalid. Enter only Y or N. Begin again? Y/N ";
		cin >> choice;
	}
	return choice;
}

any ideas? I've done a bit of looking around, but all of the explanations for these types of errors didn't seem to relate to my code...

2
Contributors
2
Replies
3
Views
4 Years
Discussion Span
Last Post by MandrewP
Featured Replies
0

Ok, so I noticed that my prototype function was titled validateWidgets and my definition was titled validateWidget, so I changed that and got rid of one of the errors, but I'm still getting the same error for the getInfo function...

1

On line 86, the parameter list doesn't match the parameter list of the prototype.

Comments
Wow, I thought I checked that too, thanks :)
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.