My task is to create a priority queue template class and show its work using different data types: int, string and any struct. I have to add, delete, print a specific element.
The class is:
template< class Type >
class PriorityList
{
private:
List<Type> elems;
As a struct I picked was this:
struct SOMESTRUCT
{
int num;
char word[];
};
As I understand a template class is a universal class which can be used for any incoming data type. I can see how to create the class for int and char [], but how do I make it work for struct too? Since you can't just write cout<< struct, neither cin>>... I'd have to create another function for inputting/outputting my struct, but if I put it in my template class, the class wouldn't be universal again.
What do I do? Also, do I have to make template or leave just one typename?