/*12.2.2
作者:Marco
*/
#include<iostream>
#include<memory>
#include<string>
#include<vector>
using namespace std;
int main()
{
allocator<string> alloc;
auto p = alloc.allocate(4);
string s;
auto q = p;
auto d = p;
/*细节真的很重要这段如果改成
while(cin >> s && q != p+4)
你就会发现要输入5个数才会终止
*/
while(q != p +4 && cin >> s)
alloc.construct(q++, s);
while (d != q)
{
cout << *d++;
}
for (--q; q != p; --q)
alloc.destroy(q);
system("pause");
return 0;
}
作者:Marco
*/
#include<iostream>
#include<memory>
#include<string>
#include<vector>
using namespace std;
int main()
{
allocator<string> alloc;
auto p = alloc.allocate(4);
string s;
auto q = p;
auto d = p;
/*细节真的很重要这段如果改成
while(cin >> s && q != p+4)
你就会发现要输入5个数才会终止
*/
while(q != p +4 && cin >> s)
alloc.construct(q++, s);
while (d != q)
{
cout << *d++;
}
for (--q; q != p; --q)
alloc.destroy(q);
system("pause");
return 0;
}