From 8296983202859318644
X-Google-Thread: f78e5,84b1489db50fe20d
X-Google-Attributes: gidf78e5,public,usenet
X-Google-Language: ENGLISH,ASCII
Path: g2news1.google.com!news3.google.com!feeder3.cambrium.nl!feeder3.cambrium.nl!feed.tweaknews.nl!63.218.45.11.MISMATCH!nx02.iad01.newshosting.com!newshosting.com!news.alt.net!comp-std-cpp-robomod!not-for-mail
From: =?iso-8859-1?q?Daniel_Kr=FCgler?= <daniel.kruegler@googlemail.com>
Newsgroups: comp.std.c++
Subject: Re: static member function and const
Date: Tue, 13 Nov 2007 10:29:27 CST
Organization: http://groups.google.com
Lines: 47
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <1194950311.581663.175280@v2g2000hsf.googlegroups.com>
References: <1194932017.215138.261760@e9g2000prf.googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1194950311 22954 127.0.0.1 (13 Nov 2007 10:38:31 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 13 Nov 2007 10:38:31 +0000 (UTC)
Return-Path: <devnull@stump.algebra.com>
X-Authentication-Warning: mulga.csse.unimelb.edu.au: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Original-To: std-c++@mailman.ucar.edu
Delivered-To: std-c++@mailman.ucar.edu
X-SMTP-Auth: no
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: v2g2000hsf.googlegroups.com; posting-host=195.137.177.243;
   posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
X-MIME-Autoconverted: from quoted-printable to 8bit by mulga.csse.unimelb.edu.au id lADAcw5P028267
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
Xref: g2news1.google.com comp.std.c++:9602

On Nov 13, 8:43 am, "subramanian10...@yahoo.com, India"
<subramanian10...@yahoo.com> wrote:
> why can't a static member function be declared as const ?
> We can declare a non-static member function as const,
> to indicate that it does not modify the non-mutable data
> members of a class.

Slightly imprecise: The const-qualification specifies whether
the member function does potentially modify a given instance
of a class, more specifically a const member function can be
thought of having a hidden this-pointer to the *const* class
type and acting with this pointer. From this we can easily
recognize that mutable operations conflict with this const-
qualification. Static member functions don't have any this
pointer.

> In the same way, is there a provision
> to indicate that a static member function does not modify
> the static data members but only uses their values ?

In C++ there does not exist the concept of a class instance,
which would be necessary to make that approach reasonable.
*If* C++ would express classes itself as first-class objects
(some other languages do this with a so-called meta class
concept), than we would probably distinguish "pure" static
member functions (which are similar to free functions and
reflect the current concept of static function members) from
"class-static" functions, which would have a hidden pointer
to the meta class object (and not an individual this pointer).
For similar reasons C++ does not support virtual static
functions (which would make sense, if you consider
polymorphic meta-classes).
If you need such behaviour, you have to create your own
meta-class approach, which is solvable via pure language
means.

HTH & Greetings from Bremen,

Daniel Kr�gler


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]



