Quote Originally Posted by Peter_APIIT
What exercise should i do ? ... How about this theory ?

I not interested in policy based design because it is compile time. Lack of flexibility.

..

What is the benefits using policy based design?

Ok, let me suggest you an example then. Suppose you're writing a report generation tool and you have an abstract class ReportGenerator structured like this:

Code:
class ReportGenerator
{
    //...
public:
    void doIt()
    {
        generateHeader();
        generateBody();
        generateTrailer();
    }

protected:
    virtual void generateHeader() = 0;
    virtual void generateBody() = 0;
    virtual void generateTrailer() = 0;
};
You can have different kinds of generators. One could generate plain text reports, other a XML report and a third a PDF report. Each one of them is supposed to implement the three generate functions. For example:

Code:
class PlainTextReportGenerator : public ReportGenerator
{
    //...
protected:
    virtual void generateHeader(){/* ... */}
    virtual void generateBody(){/* ... */}
    virtual void generateTrailer(){/* ... */}
};
Now, you're able to obtain a particular generator through a reference to ReportGenerator and call the doIt method, which defines the "template" of the generate algorithm.

Code:
    //In a real scenario you could obtain the generator from a factory.
    ReportGenerator* generator = new PlainTextReportGenerator();
    generator->doIt();
    delete generator;
The option I mentioned about using C++ templates is very similar. However, you'll loose the ability to set the desired generator at runtime (this is what you probably mentioned as "lack of flexibility"). On the other hand you'll get better performance. (The template approach is usually better suited if you're building a software library.)

Code:
template <class Generator_t>
class ReportGenerator
{
private:
    Generator_t generator_;

public:
    void doIt()
    {
        generator_.generateHeader();
        generator_.generateBody();
        generator_.generateTrailer();
    }
};
I also reminded you of policy based design because it's also an alternative for providing generic implementations for specified behaviors. If you take a look at the link I pointed in the first post, you'll get the feeling.

Now, I guess it's a matter of creating/elaborating other situations and practicing...