Thread View: comp.std.c++
2 messages
2 total messages
Started by Arthur Sombrito
Thu, 08 Oct 1992 12:36
ARM Specs Contradiction
Author: Arthur Sombrito
Date: Thu, 08 Oct 1992 12:36
Date: Thu, 08 Oct 1992 12:36
40 lines
1864 bytes
1864 bytes
--
There seems to be a contradiction in ARM specifications regarding
friend function declarations. In p. 250, it is stated that A:"If a
class or a function mentioned as a friend has not been declared
its name is entered in the same scope as the name of the class
containing the friend declaration. In p. 251, it is stated that
B:"A function first declared in a friend declaration is equivalent
to an extern declaration." Which is the correct spec: a friend
function is entered in the same scope or it is entered in file scope?
Given the ff. example w/c is similar to the one in p. 188:
class B {
class C {
friend f();
};
};
Following spec A, it would have created a B::f() member function.
I would therefore assume that spec A is applicable only to classes.
Following that assumption, it would also mean that the usual scope
resolution rules are not followed for friend functions. For example:
f();
class A { f(); };
class B {
f();
class C : public A {
friend f();
};
};
Under normal scoping rules, the sequence would have been A::f(), B::f()
and ::f(). But in this circumstances, ::f() would always be the only
function visible to the friend declaration. A::f() and B::f() could only
be made friends by adding the class qualifiers.
Comments would be greatly appreciated.
Re: ARM Specs Contradiction
Author: Andrew Koenig
Date: Fri, 09 Oct 1992 13:46
Date: Fri, 09 Oct 1992 13:46
19 lines
923 bytes
923 bytes
In article <1992Oct8.123635.10160@nuscc.nus.sg> arthur@solomon.technet.sg (Arthur Sombrito) writes:
> Which is the correct spec: a friend
> function is entered in the same scope or it is entered in file scope?
At their meeting this summer, the ISO/ANSI committee decided that friend
functions should be entered in the nearest enclosing non-class scope.
That means that
class A {
class B {
friend void f();
};
};
implicitly declares f at file scope.
--
--Andrew Koenig
ark@europa.att.com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads