mem_fun的用法,以及使用wcout

#include "stdafx.h"

#include <vector>

#include <algorithm>

#include <iostream>

#include <locale>

#include <functional>

using namespace std;



class Widget

{

public:

	Widget(wstring str)

	{

		str_ = str;

	}

	wstring str_;



	void Print()

	{

		wcout<<str_<<endl;

	}

};



void test(Widget &w)

{

	wcout<<w.str_<<endl;

}



int main()

{

	locale loc( "chs" );

	wcout.imbue( loc );

	

	vector<Widget*> w_list;

	Widget w(_T("小的"));

	w_list.push_back(&w);



	Widget w1(_T("大的"));

	w_list.push_back(&w1);





	for_each(w_list.begin(),w_list.end(),mem_fun(&Widget::Print));

	



}

你可能感兴趣的:(out)