[ create a new paste ] login | about

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

sehe - C++, pasted on Aug 22:
#include <map>
#include <string>
#include <iostream>
using namespace std;

typedef map<int, string> mymap_t;

void somefunction(mymap_t::const_iterator first, mymap_t::const_iterator last)
{
	mymap_t subclone(first, last);

	// use subclone -- it is a mymap_t now :)
	for (mymap_t::iterator it = subclone.begin(); it!=subclone.end(); ++it)
	{
		it->second += '!';
		std::cout << "first = " << it->first << ", second = " << it->second << std::endl;
	}
} 

int main()
{
	mymap_t mymap;
	mymap[1] = "One";
	mymap[2] = "Two";
	mymap[3] = "Three";


	somefunction(mymap.begin(), mymap.end());

	return 0;

}


Output:
1
2
3
first = 1, second = One!
first = 2, second = Two!
first = 3, second = Three!


Create a new paste based on this one


Comments: