C++ w/ static template methods
<p><a href="http://en.wikipedia.org/wiki/Template%5Fmethod%5Fpattern" rel="nofollow">Template methods</a> <strong>as in NOT C++ templates</strong>. </p>

<p>So, say that you would like to do some searching with different algorithms - Linear and Binary for instance. And you would also like to run those searches through some common routines so that you could, for instance,  automatically record the time that a given search took and so on. </p>

<p>The template method pattern fills the bill beautifully. The only problem is that as far as I've managed to dig around, <strong>you can't actually implement this behaviour via static methods with C++, 'cause you would also need to make the methods virtual(?)</strong> Which is of course a bit of a bummer because I don't have any need to alter the state of the search object. I would just like to pin all the searching-thingies to its own namespace. </p>

<p><strong><em>So the question is:</em></strong> <em>Would one want to use something like function/method pointers instead? Or would one just use namespaces to do the job?</em> </p>

<p>It's pretty hard to live with this kind of (dare I say) limitations with C++, as something like this would be a breeze with Java.</p>

<p><strong>Edit:</strong></p>

<p>Oh yeah, and since this is a school assignment, the use of external libraries (other than STL) isn't really an option. Sorry for the hassle. </p>
