[ create a new paste ] login | about

Link: http://codepad.org/WBwYumhz    [ raw code | output | fork ]

mohit_at_codepad - C++, pasted on Mar 2:
#include <iostream>
#include <list>
#include <vector>
using namespace std;

template <typename cont>
void printall(const cont &c) {
 for(typename cont::const_iterator it = c.begin()
     ; it != c.end()
     ; ++it) cout << *it << endl;
}

int main() {
 int nums[] = {1, 2, 3, 4, 5, 6, 7, 8};
 vector<int> vi(nums, nums + 3);
 list<int> li(nums + 4, nums + 6);
 cout << "Printing vector" << endl;
 printall(vi);
 cout << "Printing list" << endl;
 printall(li);
 return 0;
}


Output:
1
2
3
4
5
6
7
Printing vector
1
2
3
Printing list
5
6


Create a new paste based on this one


Comments: