for_each 用法!

class MapTest:public CapTest
{


private:
set <string> MyTestContain;
typedef pair <string,int> myPairDef;
typedef map <string,int> myMapDef;
myMapDef MyMap1;

public:
MapTest();
~MapTest(){};
void OutPut();
friend void MyOutPut2(myPairDef thispair);

};

void MyOutPut2(MapTest::myPairDef thispair)
{
cout<<thispair.first;
}


void MapTest::OutPut()
{

std::for_each(MyMap1.begin(), MyMap1.end(), MyOutPut2);
cout << endl;

}

原文地址:https://www.cnblogs.com/gaoxianzhi/p/3243202.html