• <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)在不僅可以閱讀類(lèi)的成員,也可以用函數(shù)名的字符串去調(diào)用函數(shù)并取得結(jié)果了。代碼與這篇文章的實(shí)例類(lèi)似,因此只貼出更改的部分以及程序截圖。

                首先為Human類(lèi)添加了成員函數(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"開(kāi)始調(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"開(kāi)始調(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"開(kāi)始調(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"開(kāi)始調(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"開(kāi)始調(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"開(kāi)始調(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     }

                最后是程序截圖:

                于是可以開(kāi)始做很多好玩的事情了。
            posted on 2009-06-29 20:47 陳梓瀚(vczh) 閱讀(4791) 評(píng)論(0)  編輯 收藏 引用 所屬分類(lèi): C++
            狠狠狠色丁香婷婷综合久久五月 | 亚洲v国产v天堂a无码久久| 国色天香久久久久久久小说| 亚洲国产精品久久| 亚洲成色999久久网站| 久久精品国产91久久麻豆自制 | 久久九九免费高清视频| 国产精品热久久毛片| 国产高清美女一级a毛片久久w| 亚洲狠狠久久综合一区77777| 高清免费久久午夜精品| 久久精品国产精品青草app| 久久噜噜电影你懂的| 久久er国产精品免费观看8| 久久精品成人免费观看97| 亚洲国产成人久久综合碰| 久久精品综合网| 天天躁日日躁狠狠久久| 精品久久久久久综合日本| 久久精品这里热有精品| 久久久久女教师免费一区| 久久免费看黄a级毛片| 久久婷婷成人综合色综合| 久久精品国产亚洲综合色| 看全色黄大色大片免费久久久 | 午夜久久久久久禁播电影| 久久被窝电影亚洲爽爽爽| 久久亚洲2019中文字幕| 亚洲精品美女久久777777| 99久久精品国产毛片| 久久国产免费直播| 国产亚洲精品自在久久| 亚洲国产精品成人久久蜜臀 | 久久精品国产亚洲综合色| 久久综合九色综合久99| 久久人人爽人人爽人人AV| 久久99久久成人免费播放| 色综合久久综合中文综合网| 91久久精品电影| 国产精品女同久久久久电影院| 久久精品亚洲男人的天堂|