Possess a use situation where

Class foo {


  static std::string make(std::string a) { .. }


I wish to make foo an abstract base class but clearly make can't be within this abstract base since virtual functions can't be static.

Such as this

Class foo {

   static virtual std::string make (std::string) = 0; //error this cannot be done 


Class fooImpl: foo{

   std::string make(std::string a) { ..}

Is making the technique non static within the abstract class or have derived classes have static techniques a good idea from the design perspective.

You may make the destructor a pure virtual function:

class foo 

You need to simply make certain to supply an implementation for that destructor anyway:


Therefore you've got a class that may be based on, but itself can't be instantiated.

The question, as published by others is whether or not the technique ought to be virtual or static.

Polymorphism is dependant on the concept that you're calling a behavior from the particular object instance no matter which kind of reference you need to it.

base& somefunction(); // may return base or derived objects
base &b = somefunction();

Now, if method behavior changes from base to derived and also you want the behaviour from the real instance you're mentioning to, you will want polymorphism and therefore an online method. The truth that the technique may or otherwise use member information is irrelevant, the key part is that it's a behavior certain to the specific instance.

Alternatively finish, static techniques are certain to the course. That's, it's a behavior from the class you coping not really a behavior from the instance being known. As a result, even when the syntax above may be used it'll call the static method at school base since that's the course that you're coping with.

There's pointless to find out that the design options you coping is preferable to another with no much deeper understanding from the domain. I really hope the reasoning above can help you come to a decision.

Wraping the static functions inside a non static virtual function enables polymorphism if you have a case and static calls whenever you don't (I can not think about any use cases when you'll just have polymorphism whenever you don't curently have a case). You loose the compile time error should you forget to place an implmentation from the static virtual inside a derived class also it is not very pretty although not anything else that you can do. It's a shame this oversight isn't being fixed within the C0x standard but it's relatively narrow requirement and so i guess there is not the demand