Aside: I have a C++ program of moderate complexity that I have to return to every 12-18 months to fix an obscure bug or add a modest festure. And every time, I spent one or two days just trying to get the thing build with the latest compiler, which picks up previously legal code and decides to whine about it, generating dozens of errors.
This is not the fault of the compiler. This is the fault of C++ for being so sloppy and complex. This is why C++ should just die and give way to Java.
Compiling a templated class that "worked previously" (under gcc3.3. as opposed to 4.x), an error was thrown on a previously acceptable and non-templated member:
/Users/agapow/Desktop/mloc/ComboMill.h:188: error: there are no arguments to 'SetMemberShip' that depend on a template parameter, so a declaration of 'SetMemberShip' must be available
Huh. A simplfied version of the class looks like this:
template class ComboMill { // ... void SetMembership (bool iIsMember) { for (int i = 0; i < mMembership.size(); i++) { mMembership[i] = iIsMember; } } void First () { // error on next line SetMembership (false); } // ... };
SetMembership is called by a number of other methods to toggle the state of set members. But that isn't the problem - the problem occurs where other methods go to callSetMembership.
It's a tough error to google for, but basically C++ is being stricter about how it identifies what you are calling. Where previously a symbol "X" would be implicitly taken to refer to amember or method "X" on the parent class, here C++ is insisting that you make it explicit. Thus it can easily be fixed by writing:
void First () { // error on next line this->SetMembership (false); } // ... };
One of the criticisms made about Python is that you have to explicitly member access qualify with "self". It seems C++ is also not longer immune form this.
简而言之,这一问题是因为compiler在不断更新出现的,要解决这一问题,只需要在出问题的函数前加上this->即可