#include "gc.h"
class CStudent{
public:
int id;
char szName[32];
};
ostream& operator<<(ostream& os, const CStudent& stu)
{
cout << stu.id << " " << stu.szName << endl;
return os;
}
int main()
{
CGCPtr<char> str;
str.New(20);
strcpy(str, "test");
cout << str << endl;
CGCPtr<CStudent> stuArray;
stuArray.New(2);
stuArray[0].id = 10;
strcpy(stuArray[0].szName, str);
stuArray[1].id = 11;
strcpy(stuArray[1].szName, str);
for(int i = 0; i < 2; i++)
cout << stuArray[i];
return 0;
}
评论2
最新资源