Error LNK2019, I cant get rid of this error

I am trying to call a function within another function but I do not want to return any values so I am using void functions. I having difficulty with passing my values, I keep getting compilation errors when I dereference or use pointers. Can someone please help me?






1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>
#include <string>
using namespace std;

void Input(string [], int*, int*);
void Process(int*, int*);
void Output(int, int, double, double, double);

void Input(string cellNumber[], int *numOfRelays, int *minutes)
{
	cout<<"Enter your Cell Phone Number: ";
	cin>>*cellNumber;
	cout<<"Enter the number of relay stations: ";
	cin>>*numOfRelays;
	cout<<"Enter the length of the call in minutes: ";
	cin>>*minutes;
	
	Process(numOfRelays, minutes);
}

void Process(int relays, int mins)
{
	double tax;
	
	if (1<=relays<=5)
		tax = .01;
	else if (6<=relays<=11)
		tax = .03;
	else if (12<=relays<=20)
		tax = .05;
	else if (21<=relays<=50)
		tax = .08;
	else if (relays>50)
		tax = .12;

	double netCost = ((0.40*relays)/50*mins);
	double taxOnCall = netCost * (tax/100);
	double totalCostOfCall = netCost + tax;
	
	Output(relays, mins, netCost, taxOnCall, totalCostOfCall);
	

}

void Output(string cellNumber, int numOfRelays, int minutes, double netCost, double taxOnCall, double totalCostOfCall)
{

	cout<<"Cell Phone Number: "<<cellNumber.substr(0,3) + "-" + cellNumber.substr(3,3) + "-" + cellNumber.substr(6,4) + "\n"<<endl;
	cout<<"Number of Relay Stations: "<<numOfRelays<<"\n"<<endl;
	cout<<"Length of Call in Minutes: "<<minutes<<"\n"<<endl;
	cout<<"Net Cost of Call: "<<netCost<<"\n"<<endl;
	cout<<"Tax of Call: "<<taxOnCall<<"\n"<<endl;
	cout<<"Total Cost of Call: "<<totalCostOfCall<<"\n"<<endl;


}
int main()
{
	string cellNumber[11];
	int numOfRelays;
	int minutes;

	Input(cellNumber, &numOfRelays, &minutes);
	
	
	return 0;
}
Last edited on
The parameters in your forward delcarlation of Process and your implementation of it do not agree.

void Process(int*, int*);
The foward declaration states Process takes two int pointers.
The implementation of Process states it takes two integers.
void Process(int relays, int mins)
These must agree.

BTW, please learn to use code tags (the <> button) when posting code.
I see at once that the declaration

void Process(int*, int*);

does not correspond to its definition

void Process(int relays, int mins)

Last edited on
This is kind of a mess. Why are you passing by pointer and not by reference? Also, what's up with the string[], a phone number can be stored as a single string (in fact that's what you are doing in "Input"). *cellNumber is the same as cellNumber[0]. You are only utilizing the first string in the array.

More to the point of your error: you declare "Process" to take two int* (pointers), but define it to take two int (integers, not pointers).

These declarations might make things easier. (See "pass by reference" http://cplusplus.com/doc/tutorial/functions2 )
1
2
3
void Input(string&, int&, int&);
void Process(int, int);
void Output(int, int, double, double, double);


Edit: If you what/need to use pointers, just be careful. Remember that an int* is not an int. An int is a number, an int pointer is an address (I know that's also a number, but please don't think of it that way.) Examples: you want to work on my house and I say "sure, come in", then hand you a piece of paper with my address on it; I bring (a copy of) my license plate to the car dealership and ask them to fix my car; The teacher asks me to buy a textbook for class and I come to class with the ISBN number/bar code; ect...
Last edited on
Nobody pointed out that you declared the following function

void Output(int, int, double, double, double);

but define it as

void Output(string cellNumber, int numOfRelays, int minutes, double netCost, double taxOnCall, double totalCostOfCall)

The definition has one additional first parameter of type string which is absent in the declaration.

So your code in whole is invalid.
Ok, I corrected the code and it compiles and runs, but when it outputs the 3 variables that do the calculations in the function "Process" do not correctly get passed to the "Output" function. It either outputs the memory address of the variable, a garbage value, or the intial value given in main. Also I've been trying to reference the variable but it wont even compile. Could someone give me some pointers? Thank you
Show the new code you have, and please format it in your post (look for the <> symbol under Format: to the right of the edit box.)
Topic archived. No new replies allowed.