How do you avoid template ambiguity when working with templates and the class keyword. consider this example where the templated item is ambiguous (I assume) because non-number values can be passed into the function that accepts the templated item.
Code:
#include <iostream>
#include <conio.h>
using namespace std;
template<class X>
long double Add(X * FirstNum, X * SecondNum);
int main(void) {
float W;
int Z;
cout << "Enter a value for w " << endl;
cin >> W;
cout << "Enter a value for z " << endl;
cin >> Z;
cout << "The value of X plus Y is " << Add(&W, &Z) << endl;
getch();
return 0;
}
template<class X>
long double Add(X * FirstNum, X * SecondNum) {
long double temp = *FirstNum + *SecondNum;
return temp;
}
However I have never actually had problems using templates whether it be with vectors or otherwise. It is just that I have never written a linked list with templates and I figured it time to do so (doesn't ever C++ programmer do that during his/her life?)
EDIT:
Oh and by the way this program was written as an example so we need not comment on anything other than templates (unless I did something blatantly wrong that will make the program not compile anyway, which I don't think I did).