From -6214776241231734829 X-Google-Thread: f78e5,84b1489db50fe20d X-Google-Attributes: gidf78e5,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!t-online.de!peer-uk.news.demon.net!kibo.news.demon.net!mutlu.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull From: AlbertoBarbati@libero.it (Alberto Ganesh Barbati) Newsgroups: comp.std.c++ Subject: Re: static member function and const Date: Tue, 13 Nov 2007 22:40:09 GMT Organization: [Infostrada] Lines: 41 Sender: mail2news@demon.net Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++) Message-ID: References: <1194932017.215138.261760@e9g2000prf.googlegroups.com> NNTP-Posting-Host: news.news.demon.net Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: news.demon.co.uk 1194993614 24062 158.152.254.254 (13 Nov 2007 22:40:14 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Tue, 13 Nov 2007 22:40:14 +0000 (UTC) X-Original-To: std-c++@mailman.ucar.edu X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov) X-User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) X-IronPort-Anti-Spam-Result: Ao8CAPqzOUfBRsBm/2dsb2JhbAA X-IronPort-Anti-Spam-Filtered: true X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au X-Path: comp-std-cpp-robomod!not-for-mail X-Received: (from fjh@localhost) by mulga.csse.unimelb.edu.au (8.13.8+Sun/8.13.8/Submit) id lADMe9b9003817; Wed, 14 Nov 2007 09:40:09 +1100 (EST) X-NNTP-Posting-Date: Tue, 13 Nov 2007 23:28:30 MET X-Delivered-To: std-c++@mailman.ucar.edu X-Authentication-Warning: mulga.csse.unimelb.edu.au: fjh set sender to devnull@stump.algebra.com using -f X-SMTP-Auth: no X-Newsgroups: comp.std.c++ Xref: g2news1.google.com comp.std.c++:9611 subramanian100in@yahoo.com, India ha scritto: > 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 ? > The const on a member function is important because it participates in overload resolution: struct A { void f(); // #1 void f() const; // #2 }; int main() { A x; x.f(); // calls #1 const A y; y.f(); // calls #2 } A const on a static member function won't participate in overload resolution (because of the absence of the "this" parameter), so it would practically serve no better purpose than a well written comment. HTH, Ganesh --- [ 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 ]