Thread View: comp.std.c++
2 messages
2 total messages
Started by linh (l.) dang
Fri, 03 Nov 1995 19:04
Re: Continue: static func() const; legal?
Author: linh (l.) dang
Date: Fri, 03 Nov 1995 19:04
Date: Fri, 03 Nov 1995 19:04
46 lines
1909 bytes
1909 bytes
Ralph Shnelvar (ralphs@tesser.com) wrote: : matt@cyclops5.berkeley.edu (Matt Austern) wrote: : >In article <478k57$5gl@stellar.comnet.com> Bret Pehrson : ><BretP@strata3d.com> writes: : > : >There's no way to declare a function such that it's prohibited from : >modifying global variables; similarly, there's no way to declare a Using GCC-xtensions one can write: void foo() __attribute__ ((const)); foo() then is a function without side-effects. Since class static variables is a subset of global-variables, a const static member functions would have no side-effects on this subset. ------------------ L.D. : >function such that it's prohibited from modifying static member : >variables. : That's a double pity. : First, it is a pity that one cannot declare a function and say "You : can't access global variables. : Second, it is a pity that class static variables cannot be defined as : untouchable. : Thanks for pointing this counter-intuitive use of : function() const : out. I actually had to run a test compilation to believe you. : Ralph : --- : [ 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. ] --- [ 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. ]
Re: Continue: static func() const; legal?
Author: Dick Menninger
Date: Tue, 07 Nov 1995 20:35
Date: Tue, 07 Nov 1995 20:35
31 lines
1651 bytes
1651 bytes
I tried to participate in this general thread earlier but my news server had severe case of out of date newsgroup tables and mailed it (and other replies) to oblivion. So this is slightly out of context. When a normal (i.e., non-static) member function is given a const qualifier, it specifies that the function does not modifies normal members of the object instance. But such a member function can diddle with static members of the class without degrading its const status (at least that is what I remember). So, if you want a means to say NO SIDE-EFFECTS WHATSOEVER, it should be done in a way that can say that for normal member functions, as well. The debate should be about whether that is a good thing to be able to say about functions. If it is, then you want to be able to say it is ALL contexts and that changes how you wind up saying it. Good Day Dick Dick.Menninger@DaytonOH.ATTGIS.COM --- [ 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. ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads