home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.std.c++:1129 comp.lang.c++:13281
- Newsgroups: comp.std.c++,comp.lang.c++
- Path: sparky!uunet!ftpbox!motsrd!news
- From: shang@corp.mot.com (David (Lujun) Shang)
- Subject: What does "::" really mean?
- Message-ID: <1992Sep4.001405.4117@cadsun.corp.mot.com>
- Sender: news@cadsun.corp.mot.com
- Reply-To: shang@corp.mot.com
- Organization: Motorola, Inc., Software Research and Development, Rolling Meadows, IL. 60008
- Date: Fri, 4 Sep 92 00:14:05 GMT
- Lines: 40
-
-
- 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
-
-