Topic: What does "::" really mean?
Author: shang@corp.mot.com (David (Lujun) Shang)
Date: Fri, 4 Sep 92 00:14:05 GMT Raw View
Basically, operator:: does not mean to qualify an identifier. It only
suggests the path to search for the identifier. For example, in expression:
anObject.aClass::aMember
anObject is the qualifier, and aClass suggests that aMember is defined in
aClass or in one of its bases.
A nested class should be a property of its enclosed class, not the property
of its object, therefore we should use expression
aEnclosingClass.aNestedClass
to access the nested class. Mircosoft C/C++7.0 choses to use
aEnclosingClass::aNestedClass
This brings ambiguity. If I have an expression:
C1::C2::C3:: ... ::X
what is the relationship of Ci and Ci-1? The base-derive relationship or
the enclosing-nested relationship? How about when the nested class happened
to be the same name of one of the base classes of its enclosing class?
(consider the fact that the name of a class member can be the same name of
its class or the base class.)
Its rather controversial to argue whether we should use "." or "::" to
access a static member. It depends whether the static member is belong
to the property of the class or the property of the object. To makes
things clear, I would rather to treat static member as the property of
the class, so we should use "." to accress a static member.
If we want to access the class property through an object, we should use
typeof(anObject).aClassProperty
David Shang
Author: shang@corp.mot.com (David (Lujun) Shang)
Date: Fri, 4 Sep 92 14:06:15 GMT Raw View
I'd like to add something to my last post on this subject.
Consider an example:
class AA
{ public:
class NAA {};
};
class AA1: public AA
{ public:
class AA
{ public:
class NAA{};
};
};
class AA2: public AA
{ public:
class AA
{ public:
class NAA{};
};
};
class BB: public AA1, public AA2
{
AA1::AA::NAA x; // what is the type of x???
};
What is the type of member "x" in class BB?
We should use:
AA1.AA.NAA
to denote the class NAA nested in class AA nested in class AA1, and use
AA1::AA.NAA
to denote the class NAA nested in the base class AA of AA1.
To conclude, we use"::" to denote a specific base when the member is ambiguous
due to multiple inheritace, and we use "." to denote the member or property of
a qualifying entity ( an object or a class ).
David Shang
Author: shang@corp.mot.com (David (Lujun) Shang)
Date: Tue, 8 Sep 92 13:43:41 GMT Raw View
In article <1992Sep4.140615.9469@cadsun.corp.mot.com> shang@corp.mot.com (David
(Lujun) Shang) writes:
> [ examples deleted]
>
> We should use:
>
> AA1.AA.NAA
>
> to denote the class NAA nested in class AA nested in class AA1, and use
>
> AA1::AA.NAA
>
> to denote the class NAA nested in the base class AA of AA1.
>
Sorry, this is a typo. I correct as follows:
We should use:
AA1::AA.NAA
to denote the class NAA nested in class AA nested in class AA1, and use
AA1::AA::NAA
to denote the class NAA nested in the base class AA of AA1.
David Shang
Author: jbn@lulea.trab.se (Johan Bengtsson)
Date: 9 Sep 92 19:40:25 GMT Raw View
shang@corp.mot.com (David (Lujun) Shang) writes:
:
: We should use:
:
: AA1::AA.NAA
:
: to denote the class NAA nested in class AA nested in class AA1, and use
:
: AA1::AA::NAA
:
: to denote the class NAA nested in the base class AA of AA1.
Since people seem to diagree what the "natural" rule is for
scope order when both nesting and inheritance are considered, I'd
rather keep AA1::AA::NAA for both cases, and require that these
expressions be unambigous.
Even if clear rules are defined, I think it will be confusing
if the same name may appear along different inheritance/nested
paths. It is (kind of) the visibility aspect of multiple inheritance
applied to nesting as well.
--
--------------------------------------------------------------------------
| Johan Bengtsson, Telia Research AB, Aurorum 6, S-951 75 Lulea, Sweden |
| Johan.Bengtsson@lulea.trab.se; Voice:(+46)92075471; Fax:(+46)92075490 |
--------------------------------------------------------------------------