>Is having static virtual functions possible in C++ ?
No.
>I know the reasoning above looks stupid but can you provide some solid grounds to it ?
No, actually your reasoning is precisely what I would use to describe the restriction. The real answer is a little more involved though.
>however, a static function is just that - its not a function
>pointer, but an object which has a static address.
You're probably thinking of the usual way of accessing a static member function:
MyClass::my_static_function();
Expecting polymorphic behavior in this case is silly unless you use templates for compile-time polymorphism:
#include <iostream>
using namespace std;
class Foo {
public:
static void bar() { cout<<"bar\n"; }
};
template <typename T>
void baz()
{
T::bar();
}
int main()
{
baz<Foo>();
}
But there's nothing in the language definition that prevents adding virtual static member functions. In fact, it would be rather simple to add the feature. The class calling mechanism (
MyClass::my_static_function();) would work the same and an extra rule could be added so that
obj->my_static_function(); calls the most derived static member function.
virtual static member functions aren't presently supported in C++, but it's not because they're impossible or illogical. It's more likely to be an oversight followed by lack of demand.