Code:
#include <iostream>
#include <string>
#include "employee.h"
#include "employee.cpp"
#include "myfuncts.h"
#include "myfuncts.cpp"
template <class Type>
Type largest(Type obj1, Type obj2, Type obj3);
template <class Type>
Type prints3(Type obj1, Type obj2, Type obj3);
int main()
{
// character input
char a, b, c;
cout << "Enter three single characters separated by a space: ";
cin >> a >> b >> c;
prints3(a, b, c);
largest(a, b, c);
// integer input
int one, two, three;
cout << "Enter three integers separated by a space: ";
cin >> one >> two >> three;
prints3(one, two, three);
largest(one, two, three);
// float input
float four, five, six;
cout << "Enter three floating point numbers separated by a space: ";
cin >> four >> five >> six;
prints3(four, five, six);
largest(four, five, six);
// double input
double seven, eight, nine;
cout << "Enter three doubles separated by a space: ";
cin >> seven >> eight >> nine;
prints3(seven, eight, nine);
largest(seven, eight, nine);
// string input
string str1, str2, str3;
cout << "Enter three strings separated by a space: ";
cin >> str1 >> str2 >> str3;
prints3(str1, str2, str3);
largest(str1, str2, str3);
// Employee input
double sal1, sal2, sal3;
Employee emp1("Donald Duck", 0);
Employee emp2("Little Bo Peep", 0);
Employee emp3("Jack Horner", 0);
cout << "Enter three employee salaries separated by a space: ";
cin >> sal1 >> sal2 >> sal3;
emp1.set_salary(sal1);
emp2.set_salary(sal2);
emp3.set_salary(sal3);
prints3(sal1, sal2, sal3);
largest(sal1, sal2, sal3);
int p1, q1, r1, *p, *q, *r;
cout << "Enter three integers separated by a space: ";
cin >> p1 >> q1 >> r1;
p = &p1;
q = &q1;
r = &r1;
prints3(*p, *q, *r);
largest(*p, *q, *r);
return 0;
}
template <class Type>
Type prints3(Type obj1, Type obj2, Type obj3)
{
cout << "You entered " << obj1 << " and " << obj2 << " and " << obj3 << endl;
}
template <class Type>
Type largest(Type obj1, Type obj2, Type obj3)
{
Type largest;
if(obj1 >= obj2 && obj1 >= obj3)
{
largest = obj1;
}
else if (obj2 >= obj1 && obj2 >= obj3)
{
largest = obj2;
}
else
largest = obj3;
cout << "Largest: " << largest << endl;
}
Thanks,