From -655324479456604236
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!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!peer-uk.news.demon.net!kibo.news.demon.net!mutlu.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull
From: tazmaster@rocketmail.com ("Jim Langston")
Newsgroups: comp.std.c++
Subject: Re: static member function and const
Date: Tue, 13 Nov 2007 17:01:54 GMT
Lines: 32
Sender: mail2news@demon.net
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <ufd_i.355$XP.244@newsfe07.lga>
References: <1194932017.215138.261760@e9g2000prf.googlegroups.com>
NNTP-Posting-Host: news.news.demon.net
X-Trace: news.demon.co.uk 1194973318 19960 158.152.254.254 (13 Nov 2007 17:01:58 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Tue, 13 Nov 2007 17:01:58 +0000 (UTC)
X-Original-To: std-c++@mailman.ucar.edu
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-Priority: 3
X-RFC2646: Format=Flowed; Original
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
X-MSMail-Priority: Normal
X-Received: (from fjh@localhost)
	by mulga.csse.unimelb.edu.au (8.13.8+Sun/8.13.8/Submit) id lADH1s9x011531;
	Wed, 14 Nov 2007 04:01:54 +1100 (EST)
X-Path: comp-std-cpp-robomod!not-for-mail
X-NNTP-Posting-Date: Tue, 13 Nov 2007 01:29:14 MST
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-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-Newsgroups: comp.std.c++
Xref: g2news1.google.com comp.std.c++:9605

<subramanian100in@yahoo.com> wrote in message 
news:1194932017.215138.261760@e9g2000prf.googlegroups.com...
> 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 ?
>
> Kindly explain.

Didn't you ask this already?  the const for a member function declares that 
the hiddent this paramater is constant.  Since a static member function does 
not have the hidden this parameter, then the const is meaningless.

That is, if the this was not hidden but had to be declared such as:

void foo::bar( foo* this, int a )
and we wanted to make it constant we would do
void foo::bar( const foo* this, int a )
but since we can't do that, because it's hidden, we put the const at the end
void foo::bar( int a ) const
that const just states that the this pointer is constant.  Since a static 
function has no this pointer to make constant, then there is no need to add 
const at the end. 

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



