#include<iostream>
#include<memory>
#include<string>
using namespace std;
int main(int argc, char* argv[])
{
allocator<string> alloc;
string s;
size_t i = 9;
auto const p = alloc.allocate(i);
auto q = p;
while (cin >> s && q != p + i)
alloc.construct(q++, s);
const size_t sz = q - p;
cout << sz << endl;
for (size_t i = 0; i != sz; i++)
cout << *(p + i) << endl;
while (q != p)
alloc.destroy(--q);
alloc.deallocate(p, i);
return 0;
}
C++ Primer 练习12.2.2
猜你喜欢
转载自blog.csdn.net/Dzx1025/article/details/107340749
今日推荐
周排行