In my book, it describe template as a tool like a stencil. It is very generic and can become any data type. I know that it can become an int, float, etc. but can it also be an user created class?
1 2 3 4 5 6 7 8
template<class T>
int Compare (T a,T b)
{
if(a==b)
returntrue;//return true if the parameters are the same
elsereturnfalse;//return false if the parameters are different
}
So in the example above, I have a template call Compare and I can compare two values. Instead of doing this Compare(1,1); can I use my own user created class? For example,Compare(Date1,Date2); and if I can compare it, will I need to change my code for my class to be compatible?