🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2371

Re: class member: static name const; Legal?

#2371
From: bs
Date: Tue, 31 Oct 1995 16:30
33 lines
1692 bytes
Bret Pehrson <BretP@strata3d.com> writes:

 > Is the following legal?
 > 
 > class base
 > {
 >   static funkie(void) const;
 > };
 > 
 > I spend 20 minutes reading the grammar and could not figure it out.  In
 > any case, my compiler complains if I mix static and const for the same
 > member function.
 > 
 > I presume that it is legal and my compiler is crap, however I would
 > rather hear that from a C++ language expert.

Think of it this way: `static' means that the member isn't associated with
any particular object of the class, it has no `this' pointer. `const' means
that the member may not modify the state of the object it is invoked for,
its `this' pointer is a pointer to const. The two notions doesn't mix and
your example is illegal.

The example is outlawed by a semantic constraint, not by a grammar rule
(in other words, it is an issue of meaning, rather than syntax).

	- Bjarne

 > Tnx.

---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <199510311501.IAA19120@ncar.ucar.EDU>
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
References: <4733v8$278@stellar.comnet.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
Date: 31 Oct 95 16:30:52 GMT
Approved: fjh@cs.mu.oz.au
X-Original-Date: 31 Oct 95 16:21:27 GMT
Organization: -
Newsgroups: comp.std.c++
From: bs@research.att.com
Message-ID: <199510311501.IAA19120@ncar.ucar.EDU>
Original-From: slocum!bs
Subject: Re: class member: static name const;  Legal?
References: <4733v8$278@stellar.comnet.com>
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMJZPaeEDnX0m9pzZAQFaEQF+LCaHaXIduS3O36YuxJ23yfwmo12xgwzH
 Zy3y3OWAJg11v/dAoFjKuNSJQNxpeZUj
 =SbTA