Pool Volume, 2 functions, some LNK Errors.

Hey Guys, Im new to this forum and a begginer on C++. I started this little program this morning, and am currently struggling with some LNK Errors. I got the first function to Work [PoolSize ()] But without the second one [FillTime ()]. What are the LNK errors for? Any help is appreciated..

error LNK2028: unresolved token (0A000528) "void __cdecl PoolSize(float,float,float,float &,float &)" (?PoolSize@@$$FYAXMMMAAM0@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)

&

error LNK2019: unresolved external symbol "void __cdecl PoolSize(float,float,float,float &,float &)" (?PoolSize@@$$FYAXMMMAAM0@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)


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
#include <iostream>
#include <iomanip>
using namespace std;


void PoolSize(float Length, float Width, float Depth, float &Gallons, float &CubicFeet);

void FillTime(float Gallons, float FillRate);

void main ()
{
	float Length;
	float Width;
	float Depth;
	float CubicFeet;
	float FillRate;
	float Gallons;

	cout << "Insert the length: ";
	cin >> Length;
	cout << "Insert the width: ";
	cin >> Width;
	cout << "Insert the depth: ";
	cin >> Depth;

	PoolSize(Length, Width, Depth, Gallons, CubicFeet);

	cout << "Insert the fill rate of the pool in gallons per minute: ";
	cin >> FillRate;
	cout << "\n";

	FillTime(Gallons, FillRate);

	system("pause");
}



//////////////////////////////Volume & Capacity///////////////////////////////////////////
void PoolSize(float Length, float Width, float Depth, float Gallons, float CubicFeet)
{

	CubicFeet = (Length*Width*Depth);
	cout << "The volume of the pool is: "<< CubicFeet << "\n\n";

	const int conversion = 7.48051948;
	
	Gallons = (CubicFeet*conversion);
	cout << "The capacity in gallons for this pool is: " << Gallons <<"\n\n";

}

//////////////////////////////////Fill Time///////////////////////////////////////////////
void FillTime(float FillRate, float Gallons)
{
	float Minutes = (Gallons/FillRate);
	cout <<"The time it takes to fill the pool with a fill rate of "<<FillRate<<" gallons per minute is: "<< Minutes <<" minutes \n\n";

}
When you call the PoolSize function on line 26. The variables Gallons and CubicFeet are both un defined. You can either move their definitions outside of the function and into the main function or you can pass the variables by reference. Which means you would have to use the "&" symbol.
The problem is that the forward declaration of the PoolSize() function doesn't match the definition in line 40: The last two floats go by reference in the forward declaration while in the definition you receive them by value. Change your forward declaration to match your definition.
Thanks hbjgd, that really helped. I finally got it.

Another question, do you have any idea how I can convert the minutes from the second function to Hours and Minutes????
use modulus operator %

http://www.cplusplus.com/doc/tutorial/operators/

go to arithmetic operators and look for modulo (%)
Topic archived. No new replies allowed.