/***********************************************
* IDE: VS2010
* FILE: print_container.h
***********************************************/
#ifndef PRINT_CONTAINER_H
#define PRINT_CONTAINER_H
#include
template
void print_container(T &c)
{
// for (T::size_type i = 0; i < c.size(); ++i)
// {
// std::cout << c[i] << std::endl;
// }
for (T::iterator beg = c.begin(); beg != c.end(); ++beg)
{
std::cout << *beg << std::endl;
}
}
#endif
/***********************************************
* IDE: VS2010
* FILE: print_container.cpp
***********************************************/
#include "print_container.h"
#include
using std::vector;
#include
using std::begin; using std::end;
int main(void)
{
int iarr[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
vector
ivec(begin(iarr), end(iarr)); print_container(ivec); return 0; }
c++_primer_exercise_1619_1620
最新推荐文章于 2015-02-27 10:22:33 发布