Preparing for my 2nd semester C++ class final here, and this is one of the practice problems we have:
Code:
//Consider the following defnition:
template<class Item>
Item maximal (Item &a, Item &b)
{
if (a > b)
return a;
else
return b;
}
//What member functions will be called from the Item class
//(assuming that all necessary functions exist)?
The question seems to be assuming that Item is a class, but from this given code, Item is just a type template parameter, and could therefore be any data type. This in no way makes it seem like Item is actually a class. I thought that maybe my teacher was being tricky, and that this is a special overridden version for Item of a broader template, but I looked up how to do that and I'm pretty sure that this isn't an example of that. I also thought that he might be trying to trick people into thinking that Item is a class when it actually isn't, but when I've asked him he seems pretty stubborn about Item being a class. This looks like just a template function which for some reason uses <class Item> instead of, say, <typename T> for the template parameter. I tried to get my teacher to clarify what he's asking for here, but somehow he thinks that it is perfectly clear (this has been a problem all year, where for some reason he thinks things are clear, and then later realizes that they aren't, but by then it's too late).
So, yeah. This question doesn't make sense to anyone I've talked to in the class. I understand everything that I've read and been taught about templates and classes, and this question just doesn't seem to make any sense. So, can anyone here maybe understand what my teacher is asking?