for_each 用法!

时间:2023-12-17 19:26:14

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;

}