• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆-341  評(píng)論-2670  文章-0  trackbacks-0
                現(xiàn)在不僅可以閱讀類的成員,也可以用函數(shù)名的字符串去調(diào)用函數(shù)并取得結(jié)果了。代碼與這篇文章的實(shí)例類似,因此只貼出更改的部分以及程序截圖。

                首先為Human類添加了成員函數(shù):
             1     void PrintHello()
             2     {
             3         GetConsole()->WriteLine(L"Hello, I\'m "+Name+L".");
             4     }
             5 
             6     VUnicodeString GetName()
             7     {
             8         return Name;
             9     }
            10 
            11     VL_AutoPtr<Animal> GetPat(VInt Index)
            12     {
            13         return OtherPats[Index];
            14     }
            15 
            16     Bird GetTransportation(VInt Index)
            17     {
            18         return OtherTranspotationsList[Index];
            19     }
            20 
            21     VBool IsAllBird(VL_AutoPtr<Animal> aAnimal , VInt Index)
            22     {
            23         return VL_AutoPtr<Bird>(aAnimal) && VL_AutoPtr<Bird>(OtherPats[Index]);
            24     }
            25 
            26     void PrintIsAllBird(VL_AutoPtr<Animal> aAnimal , VInt Index)
            27     {
            28         GetConsole()->WriteLine(IsAllBird(aAnimal,Index)?L"all bird":L"not all bird");
            29     }

                其次是注冊(cè)函數(shù)的代碼:
             1     VL_BEGIN_SUB_CLASS(Human,Mammalian)
             2         VL_ADD_CLASS_MEMBER(Name)
             3         VL_ADD_CLASS_MEMBER(MainPat)
             4         VL_ADD_CLASS_MEMBER(MainTransportation)
             5         VL_ADD_CLASS_MEMBER(OtherPats)
             6         VL_ADD_CLASS_MEMBER(OtherTranspotations)
             7         VL_ADD_CLASS_MEMBER(OtherPatsList)
             8         VL_ADD_CLASS_MEMBER(OtherTranspotationsList)
             9         VL_ADD_CLASS_MEMBER(PatMap)
            10         VL_ADD_CLASS_MEMBER(PatMultiMap)
            11         VL_ADD_CLASS_METHOD(PrintHello)
            12         VL_ADD_CLASS_METHOD(GetName)
            13         VL_ADD_CLASS_METHOD(GetPat)
            14         VL_ADD_CLASS_METHOD(GetTransportation)
            15         VL_ADD_CLASS_METHOD(IsAllBird)
            16         VL_ADD_CLASS_METHOD(PrintIsAllBird)
            17     VL_END_CLASS(Human)

                然后是調(diào)用函數(shù)的代碼。注意我們使用函數(shù)名進(jìn)行調(diào)用,參數(shù)全部使用指針,而且調(diào)用完會(huì)自動(dòng)釋放:
             1 void PrintType(VL_InspectorManager::Ptr Manager , VL_ObjectType::Ptr Type)
             2 {
             3     VL_InspectorConverterManager Converter;
             4     Converter.AddNormalConverter(new VL_InspectorReader);
             5 
             6     VL_ObjectInspector::Ptr Inspector=Manager->GetInspector(L"VL_ObjectType");
             7     GetConsole()->WriteLine(Converter.FindToStringConverter(Inspector)->ConvertToString(Inspector,Type.Object()));
             8 }
             9 
            10 //下面這里是main函數(shù)中的代碼片段
            11     {
            12         VL_AutoPtr<VL_StructInspector> HumanInspector=Manager->GetInspector(L"Human");
            13         {
            14             GetConsole()->WriteLine(L"開始調(diào)用函數(shù):PrintHello");
            15             VL_MethodInspector::Ptr Method=HumanInspector->GetMethod(L"PrintHello");
            16             VL_List<VPointer , true> Parameters;
            17             PrintResult(Method->Invoke(&human,Parameters));
            18         }
            19         {
            20             GetConsole()->WriteLine(L"開始調(diào)用函數(shù):GetName");
            21             VL_MethodInspector::Ptr Method=HumanInspector->GetMethod(L"GetName");
            22             VL_List<VPointer , true> Parameters;
            23             PrintResult(Method->Invoke(&human,Parameters));
            24         }
            25         {
            26             GetConsole()->WriteLine(L"開始調(diào)用函數(shù):GetPat");
            27             VL_MethodInspector::Ptr Method=HumanInspector->GetMethod(L"GetPat");
            28             VL_List<VPointer , true> Parameters;
            29             Parameters.Add(new int(0));
            30             PrintResult(Method->Invoke(&human,Parameters));
            31         }
            32         {
            33             GetConsole()->WriteLine(L"開始調(diào)用函數(shù):GetTransportation");
            34             VL_MethodInspector::Ptr Method=HumanInspector->GetMethod(L"GetTransportation");
            35             VL_List<VPointer , true> Parameters;
            36             Parameters.Add(new int(0));
            37             PrintResult(Method->Invoke(&human,Parameters));
            38         }
            39         {
            40             GetConsole()->WriteLine(L"開始調(diào)用函數(shù):IsAllBird");
            41             VL_MethodInspector::Ptr Method=HumanInspector->GetMethod(L"IsAllBird");
            42             VL_List<VPointer , true> Parameters;
            43             Parameters.Add(new Bird);
            44             Parameters.Add(new int(0));
            45             PrintResult(Method->Invoke(&human,Parameters));
            46         }
            47         {
            48             GetConsole()->WriteLine(L"開始調(diào)用函數(shù):PrintIsAllBird");
            49             VL_MethodInspector::Ptr Method=HumanInspector->GetMethod(L"PrintIsAllBird");
            50             VL_List<VPointer , true> Parameters;
            51             Parameters.Add(new Bird);
            52             Parameters.Add(new int(2));
            53             PrintResult(Method->Invoke(&human,Parameters));
            54         }
            55     }

                最后是程序截圖:

                于是可以開始做很多好玩的事情了。
            posted on 2009-06-29 20:47 陳梓瀚(vczh) 閱讀(4791) 評(píng)論(0)  編輯 收藏 引用 所屬分類: C++
            伊人久久大香线蕉精品不卡| 久久精品国产99国产精偷| 久久99精品久久久久久水蜜桃 | 久久综合综合久久狠狠狠97色88| 成人久久综合网| 国产精品免费久久久久久久久| 久久久久久亚洲AV无码专区| 2021最新久久久视精品爱| 日产精品久久久一区二区| 观看 国产综合久久久久鬼色 欧美 亚洲 一区二区 | 伊人久久大香线焦综合四虎| 久久精品成人欧美大片| 久久久噜噜噜www成人网| 久久精品成人免费网站| 香蕉久久av一区二区三区| 国内精品久久久久久久久| 久久久久久毛片免费播放| 伊人色综合九久久天天蜜桃 | 亚洲七七久久精品中文国产| 久久久久国产精品熟女影院| 日本亚洲色大成网站WWW久久 | 精品无码久久久久久午夜| 久久高清一级毛片| 久久AV高清无码| 亚洲AV无码久久精品色欲| 久久中文字幕人妻熟av女| 久久伊人中文无码| 久久久无码精品亚洲日韩软件| 99久久国产热无码精品免费久久久久| 99久久国产综合精品女同图片| 久久成人精品| 色综合色天天久久婷婷基地| 久久精品嫩草影院| 国产精品久久午夜夜伦鲁鲁| 久久综合久久自在自线精品自| 午夜久久久久久禁播电影| 亚洲色大成网站WWW久久九九| 中文字幕久久亚洲一区| 国产成人99久久亚洲综合精品| 99久久伊人精品综合观看| 韩国三级大全久久网站|