Is the following code correct?
#include <vector>
#include <memory>

using namespace std;

typedef vector<auto_ptr<int> > int_array;

void Test() {
  int_array a;

  for (int i = 0; i < 10; i++) {
    auto_ptr<int> p(new int(i));
    a.push_back(p);
  }
}
Explanation
No, because auto_ptr cannot be used as an element of an STL container.

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Продолжайте изучать
тесты по C++
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты