fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. void func(std::vector<int> &b){
  6. for (auto i : b)
  7. std::cout<<i<<"\n";}
  8.  
  9. void func1(std::vector<int> *b){
  10. for (auto i : *b)
  11. std::cout<<i<<"\n";}
  12.  
  13. int main() {
  14. std::vector<int> a;
  15. a.push_back(1);
  16. a.push_back(1);
  17.  
  18. func(a);
  19. std::vector<int> *c=&a;
  20. func1(c);
  21. }
Success #stdin #stdout 0.01s 5272KB
stdin
3
1 2
1 5
1 3
stdout
1
1
1
1