fork download
  1. #include <vector>
  2. #include <iostream>
  3.  
  4. struct A {
  5. int n;
  6. A(int n_) : n(n_) {}
  7. };
  8.  
  9. int main() {
  10. int arr[] = {1,2,3,4,5,6,7,8,9,10};
  11. std::vector<int> int_vec(arr, arr+10);
  12. std::vector<A> A_vec(int_vec.begin(), int_vec.end());
  13.  
  14. for( std::vector<A>::iterator it=A_vec.begin(); it!=A_vec.end(); ++it )
  15. std::cout<< it->n <<" ";
  16. std::cout<<std::endl;
  17. }
  18.  
Success #stdin #stdout 0.01s 2856KB
stdin
Standard input is empty
stdout
1 2 3 4 5 6 7 8 9 10