Function Template -

I'm having difficulty finding the problem with this code:

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
// maximum.h
// Definition of function template maximum.

template < class T > // or template< typename T >
T maximum( T value1, T value2, T value3 )
{
	T maximumValue = value1; // assume value 1 is maximum

	// determine whether value 2 is greater than maximumValue
	if ( value2 > maximumValue )
		maximumValue = value2;

	// determine whether value3 is greater than maximumValue
	if ( value3 > maximumValue )
		maximumValue = value3;

	return maximumValue;
} // end function template maximum


// Main.cpp
// Function template maximum test program.
#include <iostream>
using namespace std;

#include "maximum.h" // include definition of function template maximum

int main()
{
	// demonstrate maximum with int values
	int int1, int2, int3;

	cout << "Input three integer values: ";
	cin >> int1 >> int2 >> int3;

	// invoke in version of maximum
	cout << "The maximum integer value is: "
		<< maximum( int1, int2, int3 );

	// demonstrate maximum with double values
	double double1, double2, double3;

	cout << "\n\nInput three double values: ";
	cin >> double1 >> double2 >> double3;

	// invoke double version of maximum
	cout << "The maximum double value is: "
		<< maximum( double1, double2, double3 );

	// demonstrate maximum with char values
	char char1, char2, char3;

	cout << "\n\nInput three characters: ";
	cin >> char1, char2, char3;

	// invoke char version of maximum
	cout << "The maximum character value is: "
		<< maximum( char1, char2, char3 ) << endl;
	system("pause");
	return 0;
}


The inputs are:
1 2 3
3.3 2.2 1.1
A C B

I'm getting an error after I input B that says variabe 'char3' is being used without being initialized. I just don't see this error. Any help would be appreciated. Thanks.

return 0;

line 54 should be cin >> char1 >> char2 >> char3;
:/ can't believe I overlooked that. Thanks.
Topic archived. No new replies allowed.