Re: OT: C++ help
On Thu May 22 2008 06:34:27 Jordi Gutiérrez Hermoso wrote:
> On 21/05/2008, Mike Bird <mgb-debian@yosemite.net> wrote:
> > On Wed May 21 2008 20:01:10 Jordi Gutiérrez Hermoso wrote:
> > > So what's the fix here? Why does a using A::f declaration inside class
> > > B not work?
> >
> > There's no f(int) in scope, only int(foo).
>
> No, no, wait. This makes no sense. Consider
(two example programs snipped)
> The *only* thing that changed is the access specifiers. For some
> reason, the name lookup works and it seems that the compiler
> understands that "using A::f" means "A::f(int)" when some function is
> public but fails when the function is private, and tries instead to
> interpret "using A::f" as "A::f(C)". The first example fails to
> compile, but the second one does.
The first thing to note is that neither of these is your original
example, so it would be better if you had written "the *only*
difference between the two examples above is the access specifiers".
You then complain that it doesn't work when you try to "using" a
private function. Had you quoted the compiler's message to you,
which was probably "error: ‘virtual void A::f(foo)’ is private",
it would be immediately obvious that EITHER you know nothing of C++
INCLUSIVE OR you're deliberately wasting bandwidth on this list.
> > But the best solution is to read up on WHY C++ works this way so
> > you can understand the implications that thousands of great minds
> > have already pondered.
>
> Well, those great minds seem to be too great for me to fathom, because
> I really don't see why it seems here that a function's signature isn't
> enough to specify it, and they saw it fit to make sure I couldn't both
> I overload and inherit three related but different functions.
Exactly. Overload ambiguities are resolved in scope, not beyond.
> C++ isn't perfect, the standard isn't gospel, and I'm beginning to
> suspect a bug in gcc.
Please stop now. Thousands of people, some of them much smarter than
you or I, have not only decided that C++ should do this (which could
be a bug) but explained at great length and in great detail why C++
works this way (thus showing that it is not a bug).
You have been given a precise reference to a good example of such an
explanation but you ignore it. This was offtopic anyway. Please do
your homework and then if you still have questions address them to a
C++ forum.
--Mike Bird
Reply to: