Template functions and exception handeling
as always start by copying over all the files provided for you
The functions go in "functions.h"
File: functions.h
#pragma once
#include "cmpslib19.h"
#include "easylogging++.h"
/*
LOG THE START AND END OF ALL FUNCTIONS
THERE ARE NO try - catch blocks anywhere in this file, those would go in your main.cpp
you are throwing exeptions to exit your functions gracefully
Create the following 4 template functions
function1
T Difference(T one,T two)
name: Difference
pass by value
returns the difference between the parmaters one and two (template type)
the difference should always be positive (template type)
if the 2nd param is larger than the first throw "Invalid result"
like so
if ( one > two)
throw "Invalid Result";
while this is a template function it will only work with numeric data types
test with double and int
//-----------------------------------------------------------------------------------------------
function2
void Difference(T one,T two, T & result)
name: Difference
pass by reference
calculate the difference between the parmaters one and two, store the result in parameter three
the difference should always be positive (template type)
if the 2nd param is larger than the first throw "Invalid result"
while this is a template function it will only work with numeric data types
test with double and int
//-----------------------------------------------------------------------------------------------
function3
bool IsBetween(T one,T two, T three)
name: IsBetween
pass by value
is parameter one between parameters two (low) and three (high) the parameters are (template type)
if parameter two and three do not make a valid range throw "Invalid range"
return the result (bool)
//-----------------------------------------------------------------------------------------------
function4
void IsBetween(T one,T two, T three,bool & result)
name: IsBetween
pass by reference
is parameter one between parameters two (low) and three (high) (template type)
if parameter two and three do not make a valid range throw "Invalid range"
store the result (bool) in parameter 4
*/
functions.h -- put your functions here, template files cannot be pre compiled like we do with .cpp files
main1.cpp -- create a main to test that your functions do what they are supposed to do
for full credit:
1. In the main you will need to test ALL of your functions and make sure they are correct
2. Test each of your functions at least 3 times with disparate values
3. log the start and end of all functions at the VERY LEAST
4. make sure your code compiles with out warnings