»Ë»Ñ Æ÷·³
°³¹ßÀÚÆ÷·³ ÀÔ´Ï´Ù.
  • ºÏ¸¶Å© ¾ÆÀÌÄÜ

std::bind ÀÎÀÚ °¹¼ö µû¸¥ ÄÄÆÄÀÏ ¿À·ù Áú¹®µå¸³´Ï´Ù1

  • AStRiX
  • µî·ÏÀÏ 2016-04-30 17:37
  • Á¶È¸¼ö 333
class ClassInfo
{
public:
ClassInfo() : nID(0) {}
~ClassInfo() {}
 
bool GetInfo1(int nVal1, int& nOutVal1, std::string& strOut1, std::string& strOut2 )
{
nOutVal1 = nID;
strOut1 = "out1";
strOut2 = "out2";
return true;
}
bool GetInfo2(int nVal1, int& nOutVal1, std::string& strOut1, std::string& strOut2, std::string& strOut3 )
{
nOutVal1 = nID;
strOut1 = "out1";
strOut2 = "out2";
strOut3 = "out3";
return true;
}
 
int nID;
};
 
int main()
{
std::shared_ptr spInfo = std::make_shared ();
spInfo->nID = 10;
 
int nVal1 = 5;
int nOutVal1;
std::string strOut1;
std::string strOut2;
std::string strOut3;
 
auto _func1 = std::bind(&ClassFu::GetUserProfileInfo2, spInfo, nVal1, std::ref(nOutVal1), std::ref(strOut1), std::ref(strOut2));
_func1();
 
auto _func2 = std::bind(&ClassFu::GetUserProfileInfo2, spInfo, nVal1, std::ref(nOutVal1), std::ref(strOut1), std::ref(strOut2), std::ref(strOut3));
_func2();
}
 
ÀÌ·¯ÇÑ Äڵ忡¼­
 
auto _func1 = std::bind(&ClassInfo::GetInfo1, spInfo, nVal1, std::ref(nOutVal1), std::ref(strOut1), std::ref(strOut2));
_func1();
 
ÀÌ ÄÚµå´Â Á¤»ó ÄÄÆÄÀÏÀÌ µÇ³ª
 
auto _func2 = std::bind(&ClassInfo::GetInfo2, spInfo, nVal1, std::ref(nOutVal1), std::ref(strOut1), std::ref(strOut2), std::ref(strOut3));
_func2();
 
ÀÌ ÄÚµå´Â ÄÄÆÄÀÏ ¿À·ù°¡ ³ª°í ÀÖ½À´Ï´Ù.
¿Ö ¿¡·¯°¡ ³ª¿À´ÂÁö ¸ð¸£°Ú³×¿ä
µµ¿ò ºÎŹµå¸®°Ú½À´Ï´Ù.

 

0
ÃßõÇϱ⠴ٸ¥ÀÇ°ß 0
|
°øÀ¯¹öÆ°

´Ù¸¥ÀÇ°ß 0 Ãßõ 0 AStRiX
  • ¾Ë¸² ¿å¼³, »óó ÁÙ ¼ö ÀÖ´Â ¾ÇÇÃÀº »ï°¡ÁÖ¼¼¿ä.
©¹æ »çÁø  
¡â ÀÌÀü±Û¡ä ´ÙÀ½±Û