Here is a little test program:
#include <iostream>
class Test
{
public:
static void DoCrash(){ std::cout<< "TEST IT!"<< std::endl; }
};
int main()
{
Test k;
k.DoCrash(); // calling a static method like a member method...
std::system("pause");
return 0;
}
On VS2008 + SP1 (vc9) it compiles fine: the console just display "TEST IT!".
As far as I know, static member methods shouldn't be called on instanced object.
- Am I wrong? Is this code correct from the standard point of view?
- If it's correct, why is that? I can't find why it would be allowed, or maybe it's to help using "static or not" method in templates?