template<class T>
inline T Library<T>::get_isbn()
{
T temp;
cout << "Enter the name/no:" << endl;
cin >> temp;
string ka;
if (typeid(temp) == typeid(ka))
{
while (islower(temp[0]))
{
cout << " Pls enter the using the first letter as capital" << endl;
cin >> temp;
}
}
}
return temp;
}
I'm creating a template class which can take either integer or string
as template parameter and when I create an object of the class with T
as string
, it's going in the loop and everything's works fine. But when I create an object with int
as template parameter, it gives me following two errors:
error C1903: unable to recover from previous error(s); stopping compilation
error C2228: left of '.at' must have class/struct/union
I want that if parameter passed is string
, then only the code for checking the first alphabet to be capital should run, else when I give the template parameter as int
, it shouldn't check for the first alphabet thing.