I have this code and Im getting two errors when debugging... Im trying to change
it to arrange it but I think I have a major error.My "experience" in c++ is
veeery basic this is my third week in college :( I need help please

the errors are:


>assignment5.obj : error LNK2019: unresolved external symbol "void __cdecl results(void)" (?results@@YAXXZ) referenced in function _main
1>assignment5.obj : error LNK2019: unresolved external symbol "void __cdecl num(void)" (?num@@YAXXZ) referenced in function _main
1>H:\CS110\assignment5\Debug\assignment5.exe : fatal error LNK1120: 2 unresolved externals

code:

#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

void num();
void labels();
void separator();
void results();

int main()

//variable declaration
{
	long invoiceNumber;
	int quantity;
	float unitPrice;
	double tot;

cout<<"what is your invoice number?:";
cin>>invoiceNumber;

cout<<"What is your quantity ordered?:";
cin>>quantity;

cout<<"What is the price of the unit ordered?:";
cin>>unitPrice;

	tot=(quantity*unitPrice);
 
	cout<<endl;
	cout<<endl;
	num();
	labels();
	separator();
	results();

system("pause");
return 0;
 }

void num (long invoiceNumber)
{

 cout<<"invoice number"<<invoiceNumber<<endl;
}

void labels()

{
cout<<"Quantities"<<setw(8)<<"unit Price"<<setw(8)<<"Total"<<endl;
}

void separator()
{
cout<<"------"<<setw(8)<<"--------"<<setw(8)<<"------"<<endl;
}

void results (int quantity, float unitPrice, double tot)

{
	cout<<quantity<<setw(8)<<unitPrice<<setw(8)<<tot<<endl;

}

The functions num and results have been defined initially with no arguments.

In function main, those functions are called with no arguments.

But, while implementing the functions, arguments are present.

The linker is trying to look for the functions called in main. Since it is not able to find the functions num() and results() with no arguments it is giving this error.

Comments
thanks for the help. I didnt realize the error until you told me lol then i was like oh yea I remember the teacher said not to forget about it hehe hehe

When defining functions, you need to be sure that the prototype's and definition's arguments match exactly.

By not making sure they match, you unintentionally overloaded num() and results() to num(long) and results(int, float, double) ... sort of..... Which confuses the compiler.

When defining functions, you need to be sure that the prototype's and definition's arguments match exactly.

By not making sure they match, you unintentionally overloaded num() and results() to num(long) and results(int, float, double) ... sort of..... Which confuses the compiler.

:D thx I already made those and other changes... so now the program runs without problems ;)

So this is the "invoice " program. Tought someone might want it or might improve it or w.e. I got 100% * the program is veeery basic and can be improved with advanced techniques and w.e. for now this is the best I can do at my 3 week experience in c++ XD

#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

//including iostream, iomanip and cmath and using namespace std.
//namespace std is very helpful because if we do not use this the cout will be way 
//longer than they are. iomanip is used to setw so we could add spaces.

void numbr(long invoiceNumber);
void labels();
void separator();
void results(int quantity, float unitPrice, double tot);
// function prototypes numbr, labels separator and results.

int main()


{
	long invoiceNumber;
	int quantity;
	float unitPrice;
	double tot;
//variable declarations.
//local variables.
	cout<<"what is the invoice number?:";
	cin>>invoiceNumber;

	cout<<"What is the quantity ordered?:";
	cin>>quantity;

	cout<<"What is the price of the unit ordered?:";
	cin>>unitPrice;
	cout<<endl;
	cout<<endl;
	tot=(quantity*unitPrice);
 //gets the numbers to be used later.
// and then the program sets the formula to calculate total.
//total will be used later.

	numbr(invoiceNumber);
	cout<<endl;
	cout<<endl;
	labels();
	separator();
	results(quantity, unitPrice, tot);
	cout<<endl;
	cout<<endl;
//function calls. numbr and results have their own arguments.
system("pause");
return 0;
 }

void numbr (long invoiceNumber)
{
	cout<<"invoice number:"<<invoiceNumber<<endl;
}

void labels()

{
cout<<"Qty "<<setw(20)<<"Unit price"<<setw(20)<<"Total"<<endl;
}

void separator()
{
cout<<"------"<<setw(18)<<"---------"<<setw(21)<<"---------"<<endl;
}

void results (int quantity, float unitPrice, double tot)

{
	cout<<quantity<<setw(20)<<unitPrice<<setw(20)<<tot<<endl;

}

//function definition for numbr, separator,results and labels.
//some of them have their own parameters.

Edited 6 Years Ago by WaltP: Forget something?

This article has been dead for over six months. Start a new discussion instead.