Java compiler gripe
Suppose I accidentally give my C++ class constructor a return type:
class test { void test() {} };
GCC gives me an error:
test.cpp:4: return type specification for constructor invalid
So I go and fix it. But do the same in Java:
class test { public void test() {} }
and that isn't a constructor but a normal method. I then rack my brain for a while trying to figure out why the compiler complains about me passing in the wrong number of arguments for my constructor when I'm clearly doing nothing of the sort.
In C++, class members can't have the same name as a class (C++ Standard, §9.2, paragraph 13). But the Java Language Specification explicitly allows this (JLS, §8.4). Does anyone use this feature? Or am I just silly to want the compiler to warn me about what I'm doing?