I have a method which can receive datatype of template class type. In that function, I have to do the further processing if the datatype of the arguments is not of string type. And, if the arguments are of string type then, I want to do the exception handling.
template<class K>
class Student
{
private:
K array[10];
public:
void assignvalues( K const& index, const K& val )
{
//NOW, I want to check here that the index is not of string type
array[index] = val;
}
};
int main()
{
Student <int> object;
object.assignvalues(5,9);
//BUT THIS WILL NOT WORK
Student <string> object;
object.assignvalues("Hi","value");
return 0;
}