I'm currently working on a bit of code which takes in a value of a template of type "item." After this, it is supposed to check if the enter key is pressed or not and then return the value to be inserted into a linked list. If it is pressed without data, it then returns NULL to end the list. But none of the methods I know for checking for length or endlines work with templates to detect enter. I was wondering how I might go on carrying this out.
1 2 3 4 5 6 7 8 9 10 11 12
template<class item>
Entry<item> * Entry<item>::GetNewEntry()
{
std::cout << "Enter name (Press ENTER to quit): ";
item newName;
std::cin.get(newName); //<<<<<<<<<<<Problem here
if (newName.empty()) //<<<<<<<<<<<Problem here
return NULL;
Entry<item> *newOne = new Entry;
newOne->Set_Name(newName);
newOne->Set_Link(NULL);
return newOne;