這個模式能夠創建一個樹形結構,在同一個結構中處理嵌套菜單和菜單項組。通過菜單和項放在相同結構中,我們創建了一個“整體/部分”層次結構,即由菜單和菜單項組成的對象樹。使用組合結構,我們能把相同的操作應用在組合和個別對象上。換句話說,在大多數情況下,我們可以忽略對象組合和個別對象之間的差別。
Component:
為組合中的對象聲明接口;<喎?http://www.Bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+1NrKyrWxx+m/9s/CyrXP1sv509DA4Lmy09C907/atcTIscqh0NDOqqO7PC9wPgo8cD7J+cP30ru49r3Tv9rTw9Pat8POyrncwO1Db21wb25lbnS1xNfT1+m8/jwvcD4KPHA+1Nq13bnpveG5udbQtqjS5dK7uPa907/ao6zTw9Pat8POytK7uPa4uLK/vP6jrLKi1Nq6z8rKtcTH6b/2z8LKtc/Wy/w8L3A+CjxwPjxzdHJvbmc+TGVhZjo8L3N0cm9uZz48L3A+CjxwPtTa1+m6z9bQse3KvtK2vdq147bUz/OjrNK2vdq148O709DX073ateOjrLKitqjS5cbk0NDOqjwvcD4KPHA+PHN0cm9uZz5Db21wb3NpdGU6PC9zdHJvbmc+PC9wPgo8cD62qNLl09DX07K/vP61xMTH0Kmyv7z+tcTQ0M6qPC9wPgo8cD605rSi19Oyv7z+PC9wPgo8cD7Ktc/W0+vX07K/vP7T0LnYtcSy2df3PC9wPgo8cD48c3Ryb25nPkNsaWVudDo8L3N0cm9uZz48L3A+CjxwPs2ouf1Db21wb25lbnS907/astnX99fpus+8/rrNuPax8LbUz/OhozwvcD4KPHA+IDwvcD4KPGgxPr7ZwP2jujwvaDE+CjxwPiAgICAgICAg1Nq1/LT6xvfA/dfT1tCjrM7Sw8fPo8371NrO57LNss21pdbQ1Pa809K7t921+LXjss21paOs0rK+zcrHy7XPo837xNzIw8zwteOyzbWlseSzyc7nss2yzbWltcTSu7j21KrL2KGjPC9wPgo8cD4gICAgICAgIM7Sw8e/ydLU08PX6brPxKPKvb3ivvbV4rj2zsrM4qO60ru/qsq8ztLDx7S0vajSu7j21+m8/r3Tv9rX986qss21pbrNssu1pc/utcS5ss2svdO/2qOsyMPO0sPHxNy5u9PDzbPSu7XE1/a3qMC0tKbA7bLLtaW6zbLLtaXP7qGju7u+5Luwy7WjrM7Sw8e/ydLU1eu21LLLtaW78rLLtaXP7rX308PP4M2stcS3vbeooaPIu7rzyrXP1rLLtaXP7rrN1+m6z7LLtaXX6bz+o6zS1Lywy/vDx7j319S1xLe9t6ihozwvcD4KPGgxPlVNTMnovMajujwvaDE+CjxwPjxpbWcgc3JjPQ=="http://www.2cto.com/uploadfile/Collfiles/20140613/20140613092003187.jpg" alt="\">