类模板中的&符号问题
部分代码如下
template <class T>
class Store
{
private:
T item;
bool haveValue;
public:
Store ();
/*T &getElem ();*/
void putElem (const T &x);
};
template <class T>
Store<T>::Store ():haveValue (false)
{
}
template <class T>
/*T &Store<T>::getElem ()*/
{
if (!haveValue)
{
cout<<"No item present!"<<endl;
exit (1);
}
/*return item;*/
}
template <class T>
void Store<T>::putElem (const T &x)
{
haveValue = true;
item = x;
}