函式物件介面卡

2021-08-01 08:02:50 字數 676 閱讀 1215

#include

#include

#include

#include

#include

#include

#include

using namespace std;

//函式物件介面卡bind1st,bind2nd

struct myprint :public binary_function//binary_function《引數型別,引數型別,返回值型別》

};void test0()

for_each(v.begin(), v.end(), bind2nd(myprint(), 10));//vector元素,加10後輸出

//bind2nd,將引數繫結為函式物件的第二個引數

//bind1st,將引數繫結為函式物件的第乙個引數

}//函式物件介面卡not1,not2

struct myprint

};void test1()

//給乙個普通函式使用繫結介面卡

void fun(int v1, int v2)

void test2()

//指定某個成員函式處理成員資料

class person

void printperson()

};void test3()

int main()

介面卡模式(類介面卡 物件介面卡)

做個筆記 引用 public inte ce usb public inte ce psp public class usber implements usb 類介面卡 psp適用usb介面 public class usbadapter extends usber implements psp 物...

介面卡模式 預設介面卡,類介面卡,物件介面卡

模式思想 改變乙個類的對外介面 增加或減少 以滿足不同外部呼叫者的需求 角色成員 目標介面 target 客戶所期待的介面。目標可以是具體的或抽象的類,也可以是介面。需要適配的類 adaptee 需要適配的類或適配者類。介面卡 adapter 通過包裝乙個需要適配的物件,把原介面轉換成目標介面。適配...

介面卡模式 物件介面卡

介面卡模式 adapter 將乙個類的介面轉換成客戶希望的另外乙個介面。adapter模式使得原來由於不相容而不能一起工作的那些類可以一起工作。介面卡模式主要應用於希望復用一些現存的類,但是介面又與復用環境要求不一致的情況。在gof的設計模式中,對介面卡模式講了兩種型別,類介面卡模式和物件介面卡模式...