Modern C++ Design 第一章 Policy-Based Class Design

#include "stdafx.h"
#include
#include
using namespace std;

class RunBase
{
	virtual void go() = 0;
};

class Run100m : public RunBase
{
public:
	void go()
	{
		cout << "run 100 meters" << endl;
	}
};

class Run400m : public RunBase
{
public:
	void go()
	{
		cout << "run 400 meters" << endl;
	}
};


template
class CRun : public Policy
{
};



int main()
{ 
	CRun r1;
	r1.go();
	CRun r2;
	r2.go();
	return 0;
}

你可能感兴趣的:(Modern,C++,Design,C++)