... void __fastcall Push (UnicodeString const &documentTag, UnicodeString const &languageId);
void __fastcall Push (UnicodeString const &documentTag);
void __fastcall Push (void);
<snip...>
SUpdater updater (DisableUpdates, EnableUpdates);
SUpdater restoreIds (Push, Pop);
The first of these lines compiles without a problem, but the second one gives an error. With the code as shown above, the error is E2285 Could not find a match for 'SUpdater::SUpdater(void (_fastcall TLicTranslations::*)(const UnicodeString &,const UnicodeString &),void)'
SUpdater restoreIds(static_cast<void __fastcall(__closure*)(void)>(Push),Pop);
or perhaps
SUpdater restoreIds(static_cast<TUpdateGuardFunc>(Push),Pop);
Use static_cast to tell the compiler to which of the three Push you refer.
For whatever reason, the C++ gods have chosen static_cast as this disambiguation operator.
Initially, I just solved the problem by making a copy of the Push (void) member with a non overloaded name, and used that.
However, since then I've created a link class that passes the Push and Pop member to the TLicTranslations member stored inside as a private member. Using the same SUpdater class, this time it worked without the compiler giving a peep.
So I went back to the TLicTranslations class and it's Load member, and tried this:
SUpdater restoreIds (this->Push, this->Pop);
and to my amazement, this works. I no longer get the compiler error on this line. Remove the "this->" bits, and the error is back. Now I'm truly baffled. Inside a member function, it should make absolutely no difference if I refer to another member of the same class with or without the "this->" in front of it, but here clearly it does.
Connect with Us