C,C++ /Android_FrameWork
[SSM 안드로이드 프레임워크 개발 강의]22. 범용적 함수 포인터와 bind
k1rha
2012. 8. 15. 17:54
#include<iostream>
#include<functional>
using namespace std;
using namespace std::placeholders;
//Dialog 복사해오세요
void foo(int a) { cout << "foo" << a<< endl;}
void goo(int a, int b, int c){ cout<<"goo"<< a<<b<<c <<endl;}
//범용적 함수 포인터 - function
//
class Dialog{
public :
void Close(){cout<<"Dialog.. Close"<<endl;}
};
int main(){
function<void(int)> f = &foo;
f(1);
//f = &goo; //3개의 이자값을 1개로 대입할수 없다
f = bind(&goo,1,_1,9);
f(3);
function<void()> f2 = bind(&foo,5);
f2();
Dialog dlg;
f2=bind(&Dialog::Close,&dlg);
f2();
}