标签:str stream namespace star lan 实现 space ios cte
#include <iostream>
using namespace std;
class AbstractClass {
public:
void TemplateMethod() {
cout << "PrimitiveOperation1() Start" << endl;
PrimitiveOperation1();
cout << "PrimitiveOperation1() End" << endl;
cout << "PrimitiveOperation2() Start" << endl;
PrimitiveOperation2();
cout << "PrimitiveOperation2() End" << endl;
}
protected:
virtual void PrimitiveOperation1() {
cout << "AbstractClass Operation1" << endl;
}
virtual void PrimitiveOperation2() {
cout << "AbstractClass Operation2" << endl;
}
};
class ConcreteClass : public AbstractClass {
protected:
virtual void PrimitiveOperation1() {
cout << "ConcreteClass Operation1" << endl;
}
virtual void PrimitiveOperation2() {
cout << "ConcreteClass Operation2" << endl;
}
};
int main() {
AbstractClass * pAbstractClass = new ConcreteClass();
pAbstractClass->TemplateMethod();
if (pAbstractClass) delete pAbstractClass;
return 0;
}
标签:str stream namespace star lan 实现 space ios cte
原文地址:https://www.cnblogs.com/wstong/p/12900848.html