From -2513483554347092042
X-Google-Thread: f78e5,84b1489db50fe20d
X-Google-Attributes: gidf78e5,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news1.google.com!news1.google.com!news.glorb.com!news.alt.net!comp-std-cpp-robomod!not-for-mail
From: WaterWalk <toolmaster@163.com>
Newsgroups: comp.std.c++
Subject: Re: static member function and const
Date: Tue, 13 Nov 2007 10:30:28 CST
Organization: http://groups.google.com
Lines: 27
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <1194951083.392631.283220@e34g2000pro.googlegroups.com>
References: <1194932017.215138.261760@e9g2000prf.googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
X-Trace: posting.google.com 1194951083 25536 127.0.0.1 (13 Nov 2007 10:51:23 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 13 Nov 2007 10:51:23 +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: e34g2000pro.googlegroups.com; posting-host=219.131.196.66;
   posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
Xref: g2news1.google.com comp.std.c++:9603

On Nov 13, 3:43 pm, "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. 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 ?
>

I think one reason to use const member function is that if the
function is called via a const class object, then there shall be some
way to inform the compiler that "this function does not modify the
object". But a static member function call don't need a object of that
class.  So I don't think there is a need for const static member
function.

If you don't want a static member function modify a static member,
just take some care not to modify. Or you may use a const reference to
that static data member inside you static member function.

---
[ 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                      ]



