| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> c/c++ >> C/C++ zhong hui tiao han shu chu tan

C/C++ zhong hui tiao han shu chu tan

2008-06-01 02:09:17 编辑來源:互联网 评论
 
 
 
本文为【C/C++中回调函数初探】的拼音翻译版
  jian jie
  dui yu hen duo chu xue zhe lai shuo , wang wang jiao de hui tiao han shu hen shen mi , hen xiang zhi dao hui tiao han shu de gong zuo yuan li 。 ben wen jiang yao jie shi shen me shi hui tiao han shu 、 ta men you shen me hao chu 、 wei shen me yao shi yong ta men deng deng wen ti , zai kai shi zhi qian , jia she ni yi jing shu zhi le han shu zhi zhen 。
  shen me shi hui tiao han shu ? jian er yan zhi , hui tiao han shu jiu shi yi ge tong guo han shu zhi zhen tiao yong de han shu 。 jia ru ni ba han shu de zhi zhen ( di zhi ) zuo wei shen shu chuan di gei ling yi ge han shu , dang zhe ge zhi zhen bei yong wei tiao yong ta suo zhi xiang de han shu shi , wo men jiu shuo zhe shi hui tiao han shu 。
  wei shen me yao shi yong hui tiao han shu ?
  yin wei ke yi ba tiao yong zhe yu bei tiao yong zhe fen kai 。 tiao yong zhe bu guan xin shui shi bei tiao yong zhe , suo you ta xu zhi dao de , zhi shi cun zai yi ge ju you mou zhong te ding yuan xing 、 mou xie xian zhi tiao jian ( ru fan hui zhi wei int) de bei tiao yong han shu 。
  jia ru xiang zhi dao hui tiao han shu zai shi ji zhong you shen me zuo yong , xian jia she you zhe yang yi zhong qing kuang , wo men yao bian xie yi ge ku , ta ti gong le mou xie pai xu suan fa de shi xian , ru mao pao pai xu 、 kuai su pai xu 、shell pai xu 、shake pai xu deng deng , dan wei shi ku geng jia tong yong , bu xiang zai han shu zhong qian ru pai xu luo ji , er rang shi yong zhe lai shi xian xiang ying de luo ji ; huo zhe , xiang rang ku ke yong yu duo zhong shu ju lei xing (int、float、string), ci shi , gai zen me ban ne ? ke yi shi yong han shu zhi zhen , bing jin xing hui tiao 。
  hui tiao ke yong yu tong zhi ji zhi , li ru , you shi yao zai cheng xu zhong she zhi yi ge ji shi qi , mei dao yi ding shi jian , cheng xu hui de dao xiang ying de tong zhi , dan tong zhi ji zhi de shi xian zhe dui wo men de cheng xu yi wu suo zhi 。 er ci shi , jiu xu you yi ge te ding yuan xing de han shu zhi zhen , yong zhe ge zhi zhen lai jin xing hui tiao , lai tong zhi wo men de cheng xu shi jian yi jing fa sheng 。 shi ji shang ,SetTimer() API shi yong le yi ge hui tiao han shu lai tong zhi ji shi qi , er qie , wan yi mei you ti gong hui tiao han shu , ta huan hui ba yi ge xiao xi fa wang cheng xu de xiao xi dui lie 。
  ling yi ge shi yong hui tiao ji zhi de API han shu shi EnumWindow(), ta mei ju ping mu shang suo you de ding ceng chuang kou , wei mei ge chuang kou tiao yong yi ge cheng xu ti gong de han shu , bing chuan di chuang kou de chu li cheng xu 。 jia ru bei tiao yong zhe fan hui yi ge zhi , jiu ji xu jin xing die dai , fou ze , tui chu 。EnumWindow() bing bu guan xin bei tiao yong zhe zai he chu , ye bu guan xin bei tiao yong zhe yong ta chuan di de chu li cheng xu zuo le shen me , ta zhi guan xin fan hui zhi , yin wei ji yu fan hui zhi , ta jiang ji xu zhi xing huo tui chu 。
  bu guan zen me shuo , hui tiao han shu shi ji xu zi C yu yan de , yin er , zai C++ zhong , ying zhi zai yu C dai ma jian li jie kou , huo yu yi you de hui tiao jie kou da jiao dao shi , cai shi yong hui tiao han shu 。 chu le shang shu qing kuang , zai C++ zhong ying shi yong xu ni fang fa huo han shu fu (functor), er bu shi hui tiao han shu 。
  yi ge jian dan de hui tiao han shu shi xian
  xia mian chuang jian le yi ge sort.dll de dong tai lian jie ku , ta dao chu le yi ge ming wei CompareFunction de lei xing --typedef int (__stdcall *CompareFunction)(const byte*, const byte*), ta jiu shi hui tiao han shu de lei xing 。 ling wai , ta ye dao chu le liang ge fang fa :Bubblesort() he Quicksort(), zhe liang ge fang fa yuan xing xiang tong , dan shi xian le bu tong de pai xu suan fa 。
  void DLLDIR __stdcall Bubblesort(byte* array,int size,int elem_size,CompareFunction cmpFunc);
  void DLLDIR __stdcall Quicksort(byte* array,int size,int elem_size,CompareFunction cmpFunc);
  zhe liang ge han shu jie shou yi xia shen shu :
  ·byte * array: zhi xiang yuan su shu zu de zhi zhen ( ren yi lei xing )。
  ·int size: shu zu zhong yuan su de ge shu 。
  ·int elem_size: shu zu zhong yi ge yuan su de da xiao , yi zi jie wei dan wei 。
  ·CompareFunction cmpFunc: dai you shang shu yuan xing de zhi xiang hui tiao han shu de zhi zhen 。
  zhe liang ge han shu de hui dui shu zu jin xing mou zhong pai xu , dan mei ci dou xu jue ding liang ge yuan su na ge pai zai qian mian , er han shu zhong you yi ge hui tiao han shu , qi di zhi shi zuo wei yi ge shen shu chuan di jin lai de 。 dui bian xie zhe lai shuo , bu bi jie yi han shu zai he chu shi xian , huo ta zen yang bei shi xian de , suo xu zai yi de zhi shi liang ge yong yu bi jiao de yuan su de di zhi , bing fan hui yi xia de mou ge zhi ( ku de bian xie zhe he shi yong zhe dou bi xu zun shou zhe ge yue ding ):
  ·-1: jia ru di yi ge yuan su jiao xiao , na ta zai yi pai xu hao de shu zu zhong , ying gai pai zai di er ge yuan su qian mian 。
  ·0: jia ru liang ge yuan su xiang deng , na me ta men de xiang dui wei zhi bing bu chong yao , zai yi pai xu hao de shu zu zhong , shui zai qian mian dou wu suo wei 。
  ·1: jia ru di yi ge yuan su jiao da , na zai yi pai xu hao de shu zu zhong , ta ying gai pai di er ge yuan su hou mian 。
  ji yu yi shang yue ding , han shu Bubblesort() de shi xian ru xia ,Quicksort() jiu shao wei fu duo yi dian :
  void DLLDIR __stdcall Bubblesort(byte* array,int size,int elem_size,CompareFunction cmpFunc)
  {
  for(int i=0; i < size; i++)
  {
  for(int j=0; j < size-1; j++)
  {
  // hui tiao bi jiao han shu
  if(1 == (*cmpFunc)(array+j*elem_size,array+(j+1)*elem_size))
  {
  // liang ge xiang bi jiao de yuan su xiang jiao huan
  byte* temp = new byte[elem_size];
  memcpy(temp, array+j*elem_size, elem_size);
  memcpy(array+j*elem_size,array+(j+1)*elem_size,elem_size);
  memcpy(array+(j+1)*elem_size, temp, elem_size);
  delete [] temp;
  }
  }
  }
  }
  zhu chong : yin wei shi xian zhong shi yong le memcpy(), suo yi han shu zai shi yong de shu ju lei xing fang mian , hui you suo ju xian 。
  dui shi yong zhe lai shuo , bi xu you yi ge hui tiao han shu , qi di zhi yao chuan di gei Bubblesort() han shu 。 xia mian you er ge jian dan de shi li , yi ge bi jiao liang ge zheng shu , er ling yi ge bi jiao liang ge zi fu chuan :
  int __stdcall CompareInts(const byte* velem1, const byte* velem2)
  {
  int elem1 = *(int*)velem1;
  int elem2 = *(int*)velem2;
  if(elem1 < elem2)
  return -1;
  if(elem1 > elem2)
  return 1;
  return 0;
  }
  int __stdcall CompareStrings(const byte* velem1, const byte* velem2)
  {
  const char* elem1 = (char*)velem1;
  
   const char* elem2 = (char*)velem2;
  return strcmp(elem1, elem2);
  }
  xia mian ling you yi ge cheng xu , yong yu ce shi yi shang suo you de dai ma , ta chuan di le yi ge you 5 ge yuan su de shu zu gei Bubblesort() he Quicksort(), tong shi huan chuan di le yi ge zhi xiang hui tiao han shu de zhi zhen 。
  int main(int argc, char* argv[])
  {
  int i;
  int array[] = {5432, 4321, 3210, 2109, 1098};
  cout << "Before sorting ints with Bubblesort\n";
  for(i=0; i < 5; i++)
  cout << array[i] << '\n';
  Bubblesort((byte*)array, 5, sizeof(array[0]), &CompareInts);
  cout << "After the sorting\n";
  for(i=0; i < 5; i++)
  cout << array[i] << '\n';
  const char str[5][10] = {"estella","danielle","crissy","bo","angie"};
  cout << "Before sorting strings with Quicksort\n";
  for(i=0; i < 5; i++)
  cout << str[i] << '\n';
  Quicksort((byte*)str, 5, 10, &CompareStrings);
  cout << "After the sorting\n";
  for(i=0; i < 5; i++)
  cout << str[i] << '\n';
  return 0;
  }
  jia ru xiang jin xing jiang xu pai xu ( da yuan su zai xian ), jiu zhi xu xiu gai hui tiao han shu de dai ma , huo shi yong ling yi ge hui tiao han shu , zhe yang bian cheng qi lai ling huo xing jiu bi jiao da le 。 tiao yong yue ding
  shang mian de dai ma zhong , ke zai han shu yuan xing zhong zhao dao __stdcall, yin wei ta yi shuang xia hua xian da tou , suo yi ta shi yi ge te ding yu bian yi qi de kuo zhan , shuo dao di ye jiu shi wei ruan de shi xian 。 ren he zhi chi kai fa ji yu Win32 de cheng xu dou bi xu zhi chi zhe ge kuo zhan huo qi deng jia wu 。
   yi __stdcall biao shi de han shu shi yong le biao zhun tiao yong yue ding , wei shen me jiao biao zhun yue ding ne , yin wei suo you de Win32 API( chu le ge bie jie shou ke bian shen shu de chu wai ) dou shi yong ta 。 biao zhun tiao yong yue ding de han shu zai ta men fan hui dao tiao yong zhe zhi qian , dou hui cong dui zhan zhong yi chu diao shen shu , zhe ye shi Pascal de biao zhun yue ding 。 dan zai C/C++ zhong , tiao yong yue ding shi tiao yong zhe fu ze qing li dui zhan , er bu shi bei tiao yong han shu ; wei qiang zhi han shu shi yong C/C++ tiao yong yue ding , ke shi yong __cdecl。 ling wai , ke bian shen shu han shu ye shi yong C/C++ tiao yong yue ding 。
  Windows cao zuo xi tong cai yong le biao zhun tiao yong yue ding (Pascal yue ding ), yin wei qi ke jian xiao dai ma de ti ji 。 zhe dian dui zao qi de Windows lai shuo fei chang chong yao , yin wei na shi ta yun xing zai zhi you 640KB nei cun de dian nao shang 。
  jia ru ni bu xi huan __stdcall, huan ke yi shi yong CALLBACK hong , ta ding yi zai windef.h zhong :
  #define CALLBACK __stdcallor
  #define CALLBACK PASCAL // er PASCAL zai ci bei #defined cheng __stdcall
  zuo wei hui tiao han shu de C++ fang fa
  yin wei ping shi hen ke neng hui shi yong dao C++ bian xie dai ma , ye xu hui xiang dao ba hui tiao han shu xie cheng lei zhong de yi ge fang fa , dan xian lai kan kan yi xia de dai ma :
  class CCallbackTester
  {
  public:
  int CALLBACK CompareInts(const byte* velem1, const byte* velem2);
  };
  Bubblesort((byte*)array, 5, sizeof(array[0]),
  &CCallbackTester::CompareInts);
  jia ru shi yong wei ruan de bian yi qi , jiang hui de dao xia mian zhe ge bian yi cuo wu :
  error C2664: 'Bubblesort' : cannot convert parameter 4 from 'int (__stdcall CCallbackTester::*)(const unsigned char *,const unsigned char *)' to 'int (__stdcall *)(const unsigned char *,const unsigned char *)' There is no context in which this conversion is possible
  zhe shi yin wei fei jing tai cheng yuan han shu you yi ge e wai de shen shu :this zhi zhen , zhe jiang po shi ni zai cheng yuan han shu qian mian jia shang static。 dang ran , huan you ji zhong fang fa ke yi jie jue zhe ge wen ti , dan xian yu pian fu , jiu bu zai lun shu le 。【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
jian jie    dui yu hen duo chu xue zhe lai shuo , wang wang jiao de hui tiao han shu hen shen mi , hen xiang zhi dao hui tiao han shu de gong zuo yuan li 。 ben wen jiang yao jie shi shen me shi hui tiao han shu 、 ta men you shen me hao chu 、 wei shen me yao shi yong ta men deng deng wen ti , zai kai shi zhi qian , jia she ni yi jing shu zhi le han shu zhi zhen 。    shen me shi hui tiao han shu ?  jian er yan zhi , hui tiao han shu jiu shi yi ge tong guo han shu zhi zhen tiao yong de han shu 。 jia ru ni ba han shu de zhi zhen ( di zhi ) zuo wei shen shu chuan di gei ling yi ge han shu , dang zhe ge zhi zhen bei yong wei tiao yong ta suo zhi xiang de han shu shi , wo men jiu shuo zhe shi hui tiao han shu 。    wei shen me yao shi yong hui tiao han shu ?    yin wei ke yi ba tiao yong zhe yu bei tiao yong zhe fen kai 。 tiao yong zhe bu guan xin shui shi bei tiao yong zhe , suo you ta xu zhi dao de , zhi shi cun zai yi ge ju you mou zhong te ding yuan xing 、 mou xie xian zhi tiao jian ( ru fan hui zhi wei int) de bei tiao yong han shu 。    jia ru xiang zhi dao hui tiao han shu zai shi ji zhong you shen me zuo yong , xian jia she you zhe yang yi zhong qing kuang , wo men yao bian xie yi ge ku , ta ti gong le mou xie pai xu suan fa de shi xian , ru mao pao pai xu 、 kuai su pai xu 、shell pai xu 、shake pai xu deng deng , dan wei shi ku geng jia tong yong , bu xiang zai han shu zhong qian ru pai xu luo ji , er rang shi yong zhe lai shi xian xiang ying de luo ji ; huo zhe , xiang rang ku ke yong yu duo zhong shu ju lei xing (int、float、string), ci shi , gai zen me ban ne ? ke yi shi yong han shu zhi zhen , bing jin xing hui tiao 。    hui tiao ke yong yu tong zhi ji zhi , li ru , you shi yao zai cheng xu zhong she zhi yi ge ji shi qi , mei dao yi ding shi jian , cheng xu hui de dao xiang ying de tong zhi , dan tong zhi ji zhi de shi xian zhe dui wo men de cheng xu yi wu suo zhi 。 er ci shi , jiu xu you yi ge te ding yuan xing de han shu zhi zhen , yong zhe ge zhi zhen lai jin xing hui tiao , lai tong zhi wo men de cheng xu shi jian yi jing fa sheng 。 shi ji shang ,SetTimer() API shi yong le yi ge hui tiao han shu lai tong zhi ji shi qi , er qie , wan yi mei you ti gong hui tiao han shu , ta huan hui ba yi ge xiao xi fa wang cheng xu de xiao xi dui lie 。    ling yi ge shi yong hui tiao ji zhi de API han shu shi EnumWindow(), ta mei ju ping mu shang suo you de ding ceng chuang kou , wei mei ge chuang kou tiao yong yi ge cheng xu ti gong de han shu , bing chuan di chuang kou de chu li cheng xu 。 jia ru bei tiao yong zhe fan hui yi ge zhi , jiu ji xu jin xing die dai , fou ze , tui chu 。EnumWindow() bing bu guan xin bei tiao yong zhe zai he chu , ye bu guan xin bei tiao yong zhe yong ta chuan di de chu li cheng xu zuo le shen me , ta zhi guan xin fan hui zhi , yin wei ji yu fan hui zhi , ta jiang ji xu zhi xing huo tui chu 。    bu guan zen me shuo , hui tiao han shu shi ji xu zi C yu yan de , yin er , zai C++ zhong , ying zhi zai yu C dai ma jian li jie kou , huo yu yi you de hui tiao jie kou da jiao dao shi , cai shi yong hui tiao han shu 。 chu le shang shu qing kuang , zai C++ zhong ying shi yong xu ni fang fa huo han shu fu (functor), er bu shi hui tiao han shu 。    yi ge jian dan de hui tiao han shu shi xian    xia mian chuang jian le yi ge sort.dll de dong tai lian jie ku , ta dao chu le yi ge ming wei CompareFunction de lei xing --typedef int (__stdcall *CompareFunction)(const byte*, const byte*), ta jiu shi hui tiao han shu de lei xing 。 ling wai , ta ye dao chu le liang ge fang fa :Bubblesort() he Quicksort(), zhe liang ge fang fa yuan xing xiang tong , dan shi xian le bu tong de pai xu suan fa 。 void DLLDIR __stdcall Bubblesort(byte* array,int size,int elem_size,CompareFunction cmpFunc); void DLLDIR __stdcall Quicksort(byte* array,int size,int elem_size,CompareFunction cmpFunc);    zhe liang ge han shu jie shou yi xia shen shu :   ·byte * array: zhi xiang yuan su shu zu de zhi zhen ( ren yi lei xing )。   ·int size: shu zu zhong yuan su de ge shu 。   ·int elem_size: shu zu zhong yi ge yuan su de da xiao , yi zi jie wei dan wei 。   ·CompareFunction cmpFunc: dai you shang shu yuan xing de zhi xiang hui tiao han shu de zhi zhen 。    zhe liang ge han shu de hui dui shu zu jin xing mou zhong pai xu , dan mei ci dou xu jue ding liang ge yuan su na ge pai zai qian mian , er han shu zhong you yi ge hui tiao han shu , qi di zhi shi zuo wei yi ge shen shu chuan di jin lai de 。 dui bian xie zhe lai shuo , bu bi jie yi han shu zai he chu shi xian , huo ta zen yang bei shi xian de , suo xu zai yi de zhi shi liang ge yong yu bi jiao de yuan su de di zhi , bing fan hui yi xia de mou ge zhi ( ku de bian xie zhe he shi yong zhe dou bi xu zun shou zhe ge yue ding ):   ·-1: jia ru di yi ge yuan su jiao xiao , na ta zai yi pai xu hao de shu zu zhong , ying gai pai zai di er ge yuan su qian mian 。   ·0: jia ru liang ge yuan su xiang deng , na me ta men de xiang dui wei zhi bing bu chong yao , zai yi pai xu hao de shu zu zhong , shui zai qian mian dou wu suo wei 。   ·1: jia ru di yi ge yuan su jiao da , na zai yi pai xu hao de shu zu zhong , ta ying gai pai di er ge yuan su hou mian 。    ji yu yi shang yue ding , han shu Bubblesort() de shi xian ru xia ,Quicksort() jiu shao wei fu duo yi dian : void DLLDIR __stdcall Bubblesort(byte* array,int size,int elem_size,CompareFunction cmpFunc) {  for(int i=0; i < size; i++)  {   for(int j=0; j < size-1; j++)   {    // hui tiao bi jiao han shu    if(1 == (*cmpFunc)(array+j*elem_size,array+(j+1)*elem_size))    {     // liang ge xiang bi jiao de yuan su xiang jiao huan     byte* temp = new byte[elem_size];     memcpy(temp, array+j*elem_size, elem_size);     memcpy(array+j*elem_size,array+(j+1)*elem_size,elem_size);     memcpy(array+(j+1)*elem_size, temp, elem_size);     delete [] temp;    }   }  } }    zhu chong : yin wei shi xian zhong shi yong le memcpy(), suo yi han shu zai shi yong de shu ju lei xing fang mian , hui you suo ju xian 。    dui shi yong zhe lai shuo , bi xu you yi ge hui tiao han shu , qi di zhi yao chuan di gei Bubblesort() han shu 。 xia mian you er ge jian dan de shi li , yi ge bi jiao liang ge zheng shu , er ling yi ge bi jiao liang ge zi fu chuan : int __stdcall CompareInts(const byte* velem1, const byte* velem2) {  int elem1 = *(int*)velem1;  int elem2 = *(int*)velem2;  if(elem1 < elem2)   return -1;  if(elem1 > elem2)   return 1;  return 0; } int __stdcall CompareStrings(const byte* velem1, const byte* velem2) {  const char* elem1 = (char*)velem1;  const char* elem2 = (char*)velem2;  return strcmp(elem1, elem2); }    xia mian ling you yi ge cheng xu , yong yu ce shi yi shang suo you de dai ma , ta chuan di le yi ge you 5 ge yuan su de shu zu gei Bubblesort() he Quicksort(), tong shi huan chuan di le yi ge zhi xiang hui tiao han shu de zhi zhen 。 int main(int argc, char* argv[]) {  int i;  int array[] = {5432, 4321, 3210, 2109, 1098};  cout << "Before sorting ints with Bubblesort\n";  for(i=0; i < 5; i++)   cout << array[i] << '\n';  Bubblesort((byte*)array, 5, sizeof(array[0]), &CompareInts);  cout << "After the sorting\n";  for(i=0; i < 5; i++)   cout << array[i] << '\n';  const char str[5][10] = {"estella","danielle","crissy","bo","angie"};  cout << "Before sorting strings with Quicksort\n";  for(i=0; i < 5; i++)   cout << str[i] << '\n';  Quicksort((byte*)str, 5, 10, &CompareStrings);  cout << "After the sorting\n";  for(i=0; i < 5; i++)   cout << str[i] << '\n';  return 0; }    jia ru xiang jin xing jiang xu pai xu ( da yuan su zai xian ), jiu zhi xu xiu gai hui tiao han shu de dai ma , huo shi yong ling yi ge hui tiao han shu , zhe yang bian cheng qi lai ling huo xing jiu bi jiao da le 。 tiao yong yue ding    shang mian de dai ma zhong , ke zai han shu yuan xing zhong zhao dao __stdcall, yin wei ta yi shuang xia hua xian da tou , suo yi ta shi yi ge te ding yu bian yi qi de kuo zhan , shuo dao di ye jiu shi wei ruan de shi xian 。 ren he zhi chi kai fa ji yu Win32 de cheng xu dou bi xu zhi chi zhe ge kuo zhan huo qi deng jia wu 。 yi __stdcall biao shi de han shu shi yong le biao zhun tiao yong yue ding , wei shen me jiao biao zhun yue ding ne , yin wei suo you de Win32 API( chu le ge bie jie shou ke bian shen shu de chu wai ) dou shi yong ta 。 biao zhun tiao yong yue ding de han shu zai ta men fan hui dao tiao yong zhe zhi qian , dou hui cong dui zhan zhong yi chu diao shen shu , zhe ye shi Pascal de biao zhun yue ding 。 dan zai C/C++ zhong , tiao yong yue ding shi tiao yong zhe fu ze qing li dui zhan , er bu shi bei tiao yong han shu ; wei qiang zhi han shu shi yong C/C++ tiao yong yue ding , ke shi yong __cdecl。 ling wai , ke bian shen shu han shu ye shi yong C/C++ tiao yong yue ding 。   Windows cao zuo xi tong cai yong le biao zhun tiao yong yue ding (Pascal yue ding ), yin wei qi ke jian xiao dai ma de ti ji 。 zhe dian dui zao qi de Windows lai shuo fei chang chong yao , yin wei na shi ta yun xing zai zhi you 640KB nei cun de dian nao shang 。    jia ru ni bu xi huan __stdcall, huan ke yi shi yong CALLBACK hong , ta ding yi zai windef.h zhong : #define CALLBACK __stdcallor #define CALLBACK PASCAL // er PASCAL zai ci bei #defined cheng __stdcall    zuo wei hui tiao han shu de C++ fang fa    yin wei ping shi hen ke neng hui shi yong dao C++ bian xie dai ma , ye xu hui xiang dao ba hui tiao han shu xie cheng lei zhong de yi ge fang fa , dan xian lai kan kan yi xia de dai ma : class CCallbackTester {  public:  int CALLBACK CompareInts(const byte* velem1, const byte* velem2); }; Bubblesort((byte*)array, 5, sizeof(array[0]), &CCallbackTester::CompareInts);    jia ru shi yong wei ruan de bian yi qi , jiang hui de dao xia mian zhe ge bian yi cuo wu : error C2664: 'Bubblesort' : cannot convert parameter 4 from 'int (__stdcall CCallbackTester::*)(const unsigned char *,const unsigned char *)' to 'int (__stdcall *)(const unsigned char *,const unsigned char *)' There is no context in which this conversion is possible    zhe shi yin wei fei jing tai cheng yuan han shu you yi ge e wai de shen shu :this zhi zhen , zhe jiang po shi ni zai cheng yuan han shu qian mian jia shang static。 dang ran , huan you ji zhong fang fa ke yi jie jue zhe ge wen ti , dan xian yu pian fu , jiu bu zai lun shu le 。
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
玉美人_珠联璧合
清纯美女米卡
清新靓丽的早晨
玲子的自信与性感
痞子的甘南日记
疑是银河落九天
雪域坝上四——纯美色
冬日恋歌——西城杨柳弄轻柔
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有