A while ago, this question was asked, regarding the familiar
error: 'static' can only be specified inside the class definition
error.
In my current use-case, I am moving from a very MSVC project, where almost all the code is compiled using MSVC, and cross compiling for Android.
I noticed that there is no MSVC error, least of all, a warning, about static class methods having definitions inside (outside) the class. Am I missing something? Why is there not at least a warning?
EDIT
To clarify, I am asking why there is no proper MSVC/MSVS warning for code such as this (taken from the link, above):
class Foobar {
public:
static void do_something();
};
static void Foobar::do_something() {} // Error!
int main() {
Foobar::do_something();
}
EDIT
So sorry evey one! This sample doesn't work! My apologies.
class Foobar {
public:
template<class Y>
static int do_something();
};
template<class Y>
static int Foobar::do_something() {return 1;} // Error!
int main() {
return Foobar::do_something<double>();
}
Here is the output from MSVC 19.14 (success), and GCC 4.12 (failure).