I have a program I'm writing that reads from a file and separates the data it receives in a particular way. It is supposed to work the same way whether I give it a file of numbers or a file of strings. Right now I have it written as two separate files (I have a header and cpp for both ints and strings), but I really need it to work with just one set of files.
The problem is, I had a TERRIBLE time trying to template my class to work with both because Ive never done it before...is there any other way to try and do this? Or is templating a class the only way to get it to work with both?
ifstream fin;
fin.open("C:/Users/Josh/Desktop/TriNode/NumList.txt");
int first;
fin >> first;
cout << first;
if(first < 10)
{
trinode root(first);
list<int>::iterator currentIt;
while(!fin.eof())
{
int temp;
fin >> temp;
root.insert_node(temp);
}
}
when I try to use the trinode "root" or the iterator "currentIt" after this if statement, it keeps giving me errors saying they are not declared, which I would assume means it never gets past the IF(first <10) but If i cout << first right before, its 8.....which is obviously less than 10.