예제 #1
0
// 测试的main函数
int main()
	{
	using namespace std;

	cPerson xc(string("小菜"));

	Sneaker pqx;
	BigTrouser kk;
	TShirt dtx;

	dtx.Decorate(kk.Decorate(pqx.Decorate(&xc)));
	cout<<endl<<"第一种装扮:"<<dtx.Show()<<endl;

	LeatherShoes px;
	Tie ld;
	Suit xz;

	xz.Decorate(ld.Decorate(px.Decorate(&xc)));
	cout<<endl<<"第二种装扮:"<<xz.Show()<<endl;

	Sneaker pqx2;
	LeatherShoes px2;
	BigTrouser kk2;
	Tie ld2;
	ld2.Decorate(kk2.Decorate(px2.Decorate(pqx2.Decorate(&xc))));
	cout<<endl<<"第三种装扮:"<<ld2.Show()<<endl;

	return 0;
}
예제 #2
0
// 用戶端
int main() {
    Person *p = new Person("小李");
    BigTrouser *bt = new BigTrouser();
    TShirts *ts = new TShirts();
    bt->Decorate(p);
    ts->Decorate(bt);
    ts->Show();
    return 0;
}
예제 #3
0
int main(int argc, const char *argv[])
{
	Person *p1 = new Person("小李");
	BigTrouser *bt = new BigTrouser();
	TShirts *ts = new TShirts();
	bt->Decorate(p1);
	ts->Decorate(bt);
	ts->Show();
	return 0;
}
예제 #4
0
int mainE()
{
	Person *p = new Person("小李");
	BigTrouser *bt = new BigTrouser();
	TShirts *ts = new TShirts();

	bt->decorate(p);
	ts->decorate(bt);
	ts->show();
	cin.get();
	return 0;
}