void Store
#include
#include
using namespace std;
struct Student
{
int id;
float gpa;
};
template
class Store
{
private:
T item;
int haveValue;
public:
Store(void);
T GetElem(void);
void PutElem(T x);
};
template
Store
template
T Store
{
if (haveValue == 0)
{
cout << "No item present !" << endl;
exit(1);
}
return item;
}
template
void Store
//此处是错误的地方《》《》《》《》《》《》《
{
haveValue++;
item = x;
}
int main(void)
{
Student g = { 1000, 23 };
Store
Store
Store
s1.PutElem(3);
s2.PutElem(-7);
cout << s1.GetElem() << " " << s2.GetElem() << endl;
s3.PutElem(g);
cout << "This student id is " << s3.GetElem().id << endl;
cout << "Retrieving object D ";
cout << D.GetElem() << endl;
}