Example #1
0
int main() {
    AbstractClass *a = new AbstractClass(2);

    cout << a->getAge();

    return 0;
}
int main() {

	AbstractClass* concrete = new ConcreteClass();
	concrete->templateMethod();

	return 0;
}
Example #3
0
//客户端
int main()
{   //sean.定义一个抽象类的对象。抽象类实例不能创建即new,但可以被赋值。 
	AbstractClass* man = new Naruto();//new 的是什么对象,自然通过多态调用对应方法。 
	AbstractClass* man2 = new OnePice();
	man->Show();
	man2->Show();
    system("pause");
	return 0;
}
Example #4
0
int main()
{
	AbstractClass* man = new Naruto();
	man->Show();

	AbstractClass* man2 = new OnePice();
	man2->Show();
	system("pause");
	return 0;
}
Example #5
0
int main() 
{ 
	AbstractClass* pConcreateClass = new ConcreteClass();
	pConcreateClass->TemplateMethod();

	delete pConcreateClass; 
	
	system("pause"); 
	return 0; 
}
Example #6
0
int main()
{
	//ConcreteClassA与ConcreteClassB可相互替换
	AbstractClass* pAbstract = new ConcreteClassA();
	pAbstract->TemplateMethod();

	pAbstract = new ConcreteClassB();
	pAbstract->TemplateMethod();

	return 0;
}