Topic: Friends...
Author: arthur@solomon.technet.sg (Arthur Sombrito)
Date: Mon, 29 Jun 1992 04:49:43 GMT Raw View
Hi,
I would like to ask some questions regarding friend
declarations, if you could just bear with my ignorance.
1. Would a simple_type_name suffice for a friend class
declaration? I can't seem to find an explicit note or
example on this. AT&T cfront accepts this, but I would
just like to know if it is part of the definition.
Ex.
class A {};
class B
{
friend A; // ok?
};
2. ARM p.248 states "The name of a friend is not in the
scope of the class". Does this mean that a name used
within the class does not hide the name of a friend?
void f();
class A
{
enum f {};
friend void f(); // sees ::f() ???
};
class B
{
void f() {}
friend void f(); // sees ::f() ???
};
3. ARM p.250 states "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." I am not sure about the interpretation of
this statement for cases when the name has been used not as
a class name nor a function name.
Ex.
f();
g();
class A
{
A() {}
enum f {}; // hides ::f() ???
int g; // hides ::g()
class B
{
friend f(); // sees ::f() ???
friend g(); // since ::g() can't be seen, would
// a g() be declared w/in class A's
// scope? This would conflict with
// A::g w/c is already a non-type name.
friend A; // class A or int A::A() ???
};
};