48 lines
1.0 KiB
C++
48 lines
1.0 KiB
C++
|
#include <iostream>
|
|||
|
#include "CompositePattern.h"
|
|||
|
|
|||
|
int main()
|
|||
|
{
|
|||
|
Component *head, *sichuanBranch, *cdBranch, *myBranch, *office1, *office2, *office3,
|
|||
|
*office4, *office5, *office6, *office7, *office8;
|
|||
|
|
|||
|
head = new SubComponent("<EFBFBD>ܲ<EFBFBD>");
|
|||
|
sichuanBranch = new SubComponent("<EFBFBD>Ĵ<EFBFBD><EFBFBD>ֲ<EFBFBD>");
|
|||
|
office1 = new AdminOffice("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>칫<EFBFBD><EFBFBD>");
|
|||
|
office2 = new DeanOffice("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>칫<EFBFBD><EFBFBD>");
|
|||
|
|
|||
|
|
|||
|
cdBranch = new SubComponent("<EFBFBD>ɶ<EFBFBD><EFBFBD>ֲ<EFBFBD>");
|
|||
|
myBranch = new SubComponent("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֲ<EFBFBD>");
|
|||
|
office3 = new AdminOffice("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>칫<EFBFBD><EFBFBD>");
|
|||
|
office4 = new DeanOffice("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>칫<EFBFBD><EFBFBD>");
|
|||
|
|
|||
|
|
|||
|
office5 = new AdminOffice("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>칫<EFBFBD><EFBFBD>");
|
|||
|
office6 = new DeanOffice("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>칫<EFBFBD><EFBFBD>");
|
|||
|
|
|||
|
|
|||
|
office7 = new AdminOffice("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>칫<EFBFBD><EFBFBD>");
|
|||
|
office8 = new DeanOffice("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>칫<EFBFBD><EFBFBD>");
|
|||
|
|
|||
|
cdBranch->add(office5);
|
|||
|
cdBranch->add(office6);
|
|||
|
|
|||
|
myBranch->add(office7);
|
|||
|
myBranch->add(office8);
|
|||
|
|
|||
|
sichuanBranch->add(office3);
|
|||
|
sichuanBranch->add(office4);
|
|||
|
sichuanBranch->add(cdBranch);
|
|||
|
sichuanBranch->add(myBranch);
|
|||
|
|
|||
|
head->add(office1);
|
|||
|
head->add(office2);
|
|||
|
head->add(sichuanBranch);
|
|||
|
|
|||
|
|
|||
|
head->operation();
|
|||
|
|
|||
|
system("pause");
|
|||
|
return 0;
|
|||
|
}
|