Re: Bjarne's member function binding sample is wrong?
* George:
Hi Alf,
Yes, I am referring to the book, The C++ Programming Language, Special
Edition.
1.
How did your sample (modified one in your last post with main function)
reflects to Bjarne's point?
--------------------
unqualified name can not be bound to members of that class
--------------------
Your sample shows unqualified names are tried to bound to a member of the
class, but failed. But Bjarne mentioned, "unqualified name can not be bound
to members of that class". I can not see the logics. Could you provide more
information please?
I guess you have left out the most critical context: the phrase "that class"
implies that there is some specific example that this statement is about.
Possibly that example is like
template< class Base >
class Derived: public Base
{
public:
void foo( bar(); } // Not Base::bar().
};
Are you trying to make us guess the context of random incomplete quotes from
CLCPPP? That's silly.
2.
Notes:
[1] ?3.4.2/2 about lookup of an unqualified function call's function name: "If
the ordinary unqualified lookup of the name finds the declaration of a class
member function, the associated namespaces and classes are not considered." This
means that a member function is always the best match. Regardless of args.
It mentions if a member function matches, it will stop searches for a global
function, but in your sample, no member function matches the member function
with exact parameters, but it still stops search function in global.
So, your sample does not match your description in [1] ?3.4.2/2?
There are two phases, (1) forming a set of candidate functions, based on
function name only, and (2) resolving possible overloading, based on actual
arguments. It's phase 1, the name lookup, that stops in the class. Then phase
2 has only one candidate function, and for that function, args don't match.
Cheers, & hth.,
- Alf
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?