/*****************************************************************
// Attached: Lab11.cpp
// File: Lab11.cpp
// Programmer: Elaine Torrez
// Class: CMPR 121
*****************************************************************/
#include <iostream>
using namespace std;
// Template function prototypes
template <class T>
void getDimensions(T& side1, T& side2);
template <class T>
T calcArea(T side1, T side2);
int main()
{
// Integer variables
int side1;
int side2;
// Float variables
float width;
float length;
// Integer section
cout << "Enter the integer dimensions of a rectangle:" << endl;
getDimensions(side1, side2);
cout << "The area equals: "
<< calcArea(side1, side2) << endl << endl;
// Float section
cout << "Enter the float dimensions of a rectangle:" << endl;
getDimensions(width, length);
cout << "The area equals: "
<< calcArea(width, length) << endl;
return 0;
}
/*****************************************************************
* getDimensions
* This function gets two dimensions from the user.
*****************************************************************/
template <class T>
void getDimensions(T& side1, T& side2)
{
cout << "Enter the first dimension: ";
cin >> side1;
cout << "Enter the second dimension: ";
cin >> side2;
}
/*****************************************************************
* calcArea
* This function calculates and returns the area.
*****************************************************************/
template <class T>
T calcArea(T side1, T side2)
{
return side1 * side2;
}