Thu Nov 21 23:17:47 2024
EVENTS
 FREE
SOFTWARE
INSTITUTE

POLITICS
JOBS
MEMBERS'
CORNER

MAILING
LIST

NYLXS Mailing Lists and Archives
NYLXS Members have a lot to say and share but we don't keep many secrets. Join the Hangout Mailing List and say your peice.

DATE 2008-09-01

HANGOUT

2024-11-21 | 2024-10-21 | 2024-09-21 | 2024-08-21 | 2024-07-21 | 2024-06-21 | 2024-05-21 | 2024-04-21 | 2024-03-21 | 2024-02-21 | 2024-01-21 | 2023-12-21 | 2023-11-21 | 2023-10-21 | 2023-09-21 | 2023-08-21 | 2023-07-21 | 2023-06-21 | 2023-05-21 | 2023-04-21 | 2023-03-21 | 2023-02-21 | 2023-01-21 | 2022-12-21 | 2022-11-21 | 2022-10-21 | 2022-09-21 | 2022-08-21 | 2022-07-21 | 2022-06-21 | 2022-05-21 | 2022-04-21 | 2022-03-21 | 2022-02-21 | 2022-01-21 | 2021-12-21 | 2021-11-21 | 2021-10-21 | 2021-09-21 | 2021-08-21 | 2021-07-21 | 2021-06-21 | 2021-05-21 | 2021-04-21 | 2021-03-21 | 2021-02-21 | 2021-01-21 | 2020-12-21 | 2020-11-21 | 2020-10-21 | 2020-09-21 | 2020-08-21 | 2020-07-21 | 2020-06-21 | 2020-05-21 | 2020-04-21 | 2020-03-21 | 2020-02-21 | 2020-01-21 | 2019-12-21 | 2019-11-21 | 2019-10-21 | 2019-09-21 | 2019-08-21 | 2019-07-21 | 2019-06-21 | 2019-05-21 | 2019-04-21 | 2019-03-21 | 2019-02-21 | 2019-01-21 | 2018-12-21 | 2018-11-21 | 2018-10-21 | 2018-09-21 | 2018-08-21 | 2018-07-21 | 2018-06-21 | 2018-05-21 | 2018-04-21 | 2018-03-21 | 2018-02-21 | 2018-01-21 | 2017-12-21 | 2017-11-21 | 2017-10-21 | 2017-09-21 | 2017-08-21 | 2017-07-21 | 2017-06-21 | 2017-05-21 | 2017-04-21 | 2017-03-21 | 2017-02-21 | 2017-01-21 | 2016-12-21 | 2016-11-21 | 2016-10-21 | 2016-09-21 | 2016-08-21 | 2016-07-21 | 2016-06-21 | 2016-05-21 | 2016-04-21 | 2016-03-21 | 2016-02-21 | 2016-01-21 | 2015-12-21 | 2015-11-21 | 2015-10-21 | 2015-09-21 | 2015-08-21 | 2015-07-21 | 2015-06-21 | 2015-05-21 | 2015-04-21 | 2015-03-21 | 2015-02-21 | 2015-01-21 | 2014-12-21 | 2014-11-21 | 2014-10-21 | 2014-09-21 | 2014-08-21 | 2014-07-21 | 2014-06-21 | 2014-05-21 | 2014-04-21 | 2014-03-21 | 2014-02-21 | 2014-01-21 | 2013-12-21 | 2013-11-21 | 2013-10-21 | 2013-09-21 | 2013-08-21 | 2013-07-21 | 2013-06-21 | 2013-05-21 | 2013-04-21 | 2013-03-21 | 2013-02-21 | 2013-01-21 | 2012-12-21 | 2012-11-21 | 2012-10-21 | 2012-09-21 | 2012-08-21 | 2012-07-21 | 2012-06-21 | 2012-05-21 | 2012-04-21 | 2012-03-21 | 2012-02-21 | 2012-01-21 | 2011-12-21 | 2011-11-21 | 2011-10-21 | 2011-09-21 | 2011-08-21 | 2011-07-21 | 2011-06-21 | 2011-05-21 | 2011-04-21 | 2011-03-21 | 2011-02-21 | 2011-01-21 | 2010-12-21 | 2010-11-21 | 2010-10-21 | 2010-09-21 | 2010-08-21 | 2010-07-21 | 2010-06-21 | 2010-05-21 | 2010-04-21 | 2010-03-21 | 2010-02-21 | 2010-01-21 | 2009-12-21 | 2009-11-21 | 2009-10-21 | 2009-09-21 | 2009-08-21 | 2009-07-21 | 2009-06-21 | 2009-05-21 | 2009-04-21 | 2009-03-21 | 2009-02-21 | 2009-01-21 | 2008-12-21 | 2008-11-21 | 2008-10-21 | 2008-09-21 | 2008-08-21 | 2008-07-21 | 2008-06-21 | 2008-05-21 | 2008-04-21 | 2008-03-21 | 2008-02-21 | 2008-01-21 | 2007-12-21 | 2007-11-21 | 2007-10-21 | 2007-09-21 | 2007-08-21 | 2007-07-21 | 2007-06-21 | 2007-05-21 | 2007-04-21 | 2007-03-21 | 2007-02-21 | 2007-01-21 | 2006-12-21 | 2006-11-21 | 2006-10-21 | 2006-09-21 | 2006-08-21 | 2006-07-21 | 2006-06-21 | 2006-05-21 | 2006-04-21 | 2006-03-21 | 2006-02-21 | 2006-01-21 | 2005-12-21 | 2005-11-21 | 2005-10-21 | 2005-09-21 | 2005-08-21 | 2005-07-21 | 2005-06-21 | 2005-05-21 | 2005-04-21 | 2005-03-21 | 2005-02-21 | 2005-01-21 | 2004-12-21 | 2004-11-21 | 2004-10-21 | 2004-09-21 | 2004-08-21 | 2004-07-21 | 2004-06-21 | 2004-05-21 | 2004-04-21 | 2004-03-21 | 2004-02-21 | 2004-01-21 | 2003-12-21 | 2003-11-21 | 2003-10-21 | 2003-09-21 | 2003-08-21 | 2003-07-21 | 2003-06-21 | 2003-05-21 | 2003-04-21 | 2003-03-21 | 2003-02-21 | 2003-01-21 | 2002-12-21 | 2002-11-21 | 2002-10-21 | 2002-09-21 | 2002-08-21 | 2002-07-21 | 2002-06-21 | 2002-05-21 | 2002-04-21 | 2002-03-21 | 2002-02-21 | 2002-01-21 | 2001-12-21 | 2001-11-21 | 2001-10-21 | 2001-09-21 | 2001-08-21 | 2001-07-21 | 2001-06-21 | 2001-05-21 | 2001-04-21 | 2001-03-21 | 2001-02-21 | 2001-01-21 | 2000-12-21 | 2000-11-21 | 2000-10-21 | 2000-09-21 | 2000-08-21 | 2000-07-21 | 2000-06-21 | 2000-05-21 | 2000-04-21 | 2000-03-21 | 2000-02-21 | 2000-01-21 | 1999-12-21

Key: Value:

Key: Value:

MESSAGE
DATE 2008-09-03
FROM Ruben Safir
SUBJECT Subject: [NYLXS - HANGOUT] C++ Workshop Const Functions
Date: Sun, 31 Aug 2008 02:28:47 -0500
From: Paavo Helde
Lines: 61
Message-ID:
NNTP-Posting-Date: Sun, 31 Aug 2008 02:28:47 -0500
Newsgroups: comp.lang.c++
Path:
reader1.panix.com!panix!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!newsfeed.cwix.com!dc3peer2.nntp.savvis.net!peer.nntp.savvis.net!cycny02.gnilink.net!cyclone1.gnilink.net!gnilink.net!nx01.iad01.newshosting.com!newshosting.com!216.196.98.140.MISMATCH!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local02.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail
References:



Subject: Re: error: passing `const Weight' as `this'
argument of `float Weight::wgt()' discards qualifiers
User-Agent: Xnews/5.04.25
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your
complaint properly
X-Complaints-To: abuse-at-giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Postfilter: 1.3.39
X-Trace:
sv3-zSNH/CfU/RfOVKi6IK9qk51Y6F54YSOTRXqItMKO02dvVAoMeeeBQWpqroTC/2K3Wc8R77P6irb4kMd!dwiE/BMzw9Bb9OCwBI6nrMTLMlwlglOTNgk5Dy0sS5a1LZ042vB4rt5576MFUFxj38Ake7Vz
X-Usenet-Provider: http://www.giganews.com
Xref: panix comp.lang.c++:1019775
MIME-Version: 1.0
Content-Type: text/plain

Ruben kirjutas:

> On Sat, 30 Aug 2008 01:39:48 -0500, Paavo Helde wrote:
>
>>> Weight& Weight::operator=(const Weight &fweight) {
>>> wgt_ = fweight.wgt();
>>
>> And here you call it through a const Weight reference.
>>
>> Make your getter methods const member functions.
>
> what does making the fuction const do practically? If I make a const
> function that assings some member a value, will it compile?

No, it will not, and that's the point of the const system. It holds your
hand and tries to prevent you shoot in your leg.

Some people argue that constness it not the only or most important
aspect
to keep in mind when working with objects, and there should be no
obligation to use it. However, it has been built into the language (in
signatures of assignment op and copy ctor and the rule about binding
temporaries to const references) as well as into the standard library,
so
practically there is no alternative to making all code const-correct
from
the start.

Here, the standard signature for assignment op is as you wrote:

Weight& Weight::operator=(const Weight &fweight);

The constness of the argument now propagates further to every use of the
fweight reference. I try to explain the propagation mechanism in more
detail, feel free to use your books instead if I am not making any sense
;-)

The signature promises that inside this function the fweight argument is
kept const. Now you are calling function fweight.wgt() which is
non-const
and thus may potentially modify the object referenced by fweight. Thus
the
compiler cannot be sure it can keep up with the promises of operator= ()
signature, so the compilation is aborted.

Now, if you make wgt() const,

class Weight {
public:
float wgt() const { return wgt_; };


Now the operator=() is happy and compiles. OTOH, if you had called some
non-const member function on the same object from wgt(), you would have
got another error there, i.e. the error will also "propagate". Now you
could add 'const' to this next member function and see if the thing
compiles, etc.

However, making the code const-correct this way is quite tedious, better
is to decide up-front which member functions should not modify the
object,
and mark them 'const' from the start. The "getter" functions like wgt()
are the obvious candidates.

hth
Paavo

--
http://www.mrbrklyn.com - Interesting Stuff
http://www.nylxs.com - Leadership Development in Free Software

So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998

http://fairuse.nylxs.com DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002

"Yeah - I write Free Software...so SUE ME"

"The tremendous problem we face is that we are becoming sharecroppers to our own cultural heritage -- we need the ability to participate in our own society."

"> I'm an engineer. I choose the best tool for the job, politics be damned.<
You must be a stupid engineer then, because politcs and technology have been attached at the hip since the 1st dynasty in Ancient Egypt. I guess you missed that one."

© Copyright for the Digital Millennium

  1. 2008-09-03 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] C++ Workshop Const Functions
  2. 2008-09-03 swd <sderrick-at-optonline.net> Subject: [NYLXS - HANGOUT] InstallFeast scheduled anytime soon? Thanks.
  3. 2008-09-07 Elfen Magix <elfen_magix-at-yahoo.com> Subject: [NYLXS - HANGOUT] Multiple Webservers, 1 IP#
  4. 2008-09-07 Elfen Magix <elfen_magix-at-yahoo.com> Subject: [NYLXS - HANGOUT] Multiple Webservers, 1 IP#
  5. 2008-09-07 Ruben Safir <ruben-at-mrbrklyn.com> Re: [NYLXS - HANGOUT] Multiple Webservers, 1 IP#
  6. 2008-09-07 Elfen Magix <elfen_magix-at-yahoo.com> Re: [NYLXS - HANGOUT] Multiple Webservers, 1 IP#
  7. 2008-09-07 Ruben Safir <ruben-at-mrbrklyn.com> Re: [NYLXS - HANGOUT] Multiple Webservers, 1 IP#
  8. 2008-09-07 Elfen Magix <elfen_magix-at-yahoo.com> Re: [NYLXS - HANGOUT] Multiple Webservers, 1 IP#
  9. 2008-09-07 Ruben Safir <ruben-at-mrbrklyn.com> Re: [NYLXS - HANGOUT] Multiple Webservers, 1 IP#
  10. 2008-09-07 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] installing gtk and gtkmm by hand
  11. 2008-09-08 From: =?utf-8?B?SmFzb24gSGFyZG91aW4=?= <jhardouin-at-infoblox.com> Subject: [NYLXS - HANGOUT] =?utf-8?B?Q3JpY2tldCBMaXUgRXZlbnQ6IFBhdGNoIE5vdyBvciBQYXkgTGF0ZXI6IE5ZQywgT2N0b2JlciAx?=
  12. 2008-09-10 Ruben <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] Vectors as parameters in constructors
  13. 2008-09-11 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] 9-11
  14. 2008-09-11 From: "Ronny Abraham" <ronny.coder-at-gmail.com> Re: [NYLXS - HANGOUT] 9-11
  15. 2008-09-11 Contrarian <adrba-at-nyct.net> Re: [NYLXS - HANGOUT] 9-11
  16. 2008-09-11 From: <mlr52-at-michaellrichardson.com> Re: [NYLXS - HANGOUT] 9-11
  17. 2008-09-12 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] In case you missed it
  18. 2008-09-12 einker <eminker-at-gmail.com> Re: [NYLXS - HANGOUT] In case you missed it
  19. 2008-09-12 Elfen Magix <elfen_magix-at-yahoo.com> Re: [NYLXS - HANGOUT] In case you missed it
  20. 2008-09-12 Elfen Magix <elfen_magix-at-yahoo.com> Re: [NYLXS - HANGOUT] Multiple Webservers, 1 IP#
  21. 2008-09-12 Ruben Safir <ruben-at-mrbrklyn.com> Re: [NYLXS - HANGOUT] Multiple Webservers, 1 IP#
  22. 2008-09-12 swd <sderrick-at-optonline.net> Subject: [NYLXS - HANGOUT]
  23. 2008-09-12 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] Its a war
  24. 2008-09-12 Elfen Magix <elfen_magix-at-yahoo.com> Re: [NYLXS - HANGOUT] Multiple Webservers, 1 IP#
  25. 2008-09-15 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] Gimp Filters
  26. 2008-09-16 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] [malmonte-at-searchedp.com: HP-UX Senior Systems Analyst.]
  27. 2008-09-16 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [ruben-at-mrbrklyn.com: [NYLXS - HANGOUT] Free Software Chamber of Commerce: Healthcare Focus] 13 O Aug 11 Jesse Becker ( 26) Re: [Dclug] Results
  28. 2008-09-16 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] Next NYLXS Meeting
  29. 2008-09-16 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] Meetup.Com
  30. 2008-09-16 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] Living On Cat Food
  31. 2008-09-16 From: "Ronny Abraham" <ronny.coder-at-gmail.com> Re: [NYLXS - HANGOUT] Living On Cat Food
  32. 2008-09-16 Ron Guerin <ron-at-vnetworx.net> Re: [NYLXS - HANGOUT] Living On Cat Food
  33. 2008-09-16 Ruben Safir <ruben-at-mrbrklyn.com> Re: [NYLXS - HANGOUT] Living On Cat Food
  34. 2008-09-16 Ruben Safir <ruben-at-mrbrklyn.com> Re: [NYLXS - HANGOUT] Living On Cat Food
  35. 2008-09-16 From: =?utf-8?B?SmFzb24gSGFyZG91aW4=?= <jhardouin-at-infoblox.com> Subject: [NYLXS - HANGOUT] =?utf-8?B?Q3JpY2tldCBMaXUgRXZlbnQ6IFBhdGNoIE5vdyBvciBQYXkgTGF0ZXI6IE5ZQywgT2N0b2JlciAx?=
  36. 2008-09-16 Ruben Safir <ruben-at-mrbrklyn.com> Re: [NYLXS - HANGOUT] Cricket Liu Event: Patch Now or Pay Later: NYC, October 1
  37. 2008-09-16 From: "Ronny Abraham" <ronny.coder-at-gmail.com> Re: [NYLXS - HANGOUT] Living On Cat Food
  38. 2008-09-16 Ruben Safir <ruben-at-mrbrklyn.com> Re: [NYLXS - HANGOUT] Living On Cat Food
  39. 2008-09-16 From: "Ronny Abraham" <ronny.coder-at-gmail.com> Re: [NYLXS - HANGOUT] Living On Cat Food
  40. 2008-09-16 einker <eminker-at-gmail.com> Subject: [NYLXS - HANGOUT] Lenovo halts online sales of Linux-based PCs
  41. 2008-09-16 Elfen Magix <elfen_magix-at-yahoo.com> Re: [NYLXS - HANGOUT] Next NYLXS Meeting
  42. 2008-09-16 Elfen Magix <elfen_magix-at-yahoo.com> Re: [NYLXS - HANGOUT] Living On Cat Food
  43. 2008-09-16 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] [Events-at-enterpriseannounce.com: Join Us - Exclusive Executive Luncheon]
  44. 2008-09-16 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] C++ Instructor
  45. 2008-09-17 Ron Guerin <ron-at-vnetworx.net> Re: [NYLXS - HANGOUT] Living On Cat Food
  46. 2008-09-17 Ruben Safir <ruben-at-mrbrklyn.com> Re: [NYLXS - HANGOUT] Living On Cat Food
  47. 2008-09-17 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] [raj-at-brainlink.com: Followup from our call]
  48. 2008-09-17 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] [malmonte-at-searchedp.com: Website Project/Technical Manager.]
  49. 2008-09-17 email <ray-pub-at-rcn.com> Re: [NYLXS - HANGOUT] Living On Cat Food
  50. 2008-09-18 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] NYLXS Meeting
  51. 2008-09-18 richard-at-weait.com Subject: [NYLXS - HANGOUT] NYC Open Source Mapping event this weekend
  52. 2008-09-21 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] DRM is Theft
  53. 2008-09-21 Kevin Mark <kevin.mark-at-verizon.net> Re: [NYLXS - HANGOUT] DRM is Theft
  54. 2008-09-21 Ruben Safir <ruben-at-mrbrklyn.com> Re: [NYLXS - HANGOUT] DRM is Theft
  55. 2008-09-22 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] Meeting Tomorrow
  56. 2008-09-22 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] [Events-at-enterpriseannounce.com: Join Us - Exclusive Seminar at Smith & Wollensky]
  57. 2008-09-23 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] [malmonte-at-searchedp.com: PERL Developer]
  58. 2008-09-23 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] Killing a Posted Refresh
  59. 2008-09-24 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] Advanced Internet in Jersey City
  60. 2008-09-24 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] Glade-- for SuSE 9.4 or 9.3
  61. 2008-09-25 swd <sderrick-at-optonline.net> Re: [NYLXS - HANGOUT] Meeting Tomorrow
  62. 2008-09-25 Ruben Safir <ruben-at-mrbrklyn.com> Re: [NYLXS - HANGOUT] Meeting Tomorrow
  63. 2008-09-25 swd <sderrick-at-optonline.net> Re: [NYLXS - HANGOUT] Meeting Tomorrow
  64. 2008-09-29 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] Shana Tova
  65. 2008-09-29 Elfen Magix <elfen_magix-at-yahoo.com> Re: [NYLXS - HANGOUT] Shana Tova
  66. 2008-09-29 From: "Paul Robert Marino" <prmarino1-at-gmail.com> Re: [NYLXS - HANGOUT] Shana Tova
  67. 2008-09-29 From: "Paul Robert Marino" <prmarino1-at-gmail.com> Re: [NYLXS - HANGOUT] Shana Tova
  68. 2008-09-29 email <ray-pub-at-rcn.com> Subject: [NYLXS - HANGOUT] wget & mirrors
  69. 2008-09-30 Mark Simko <msimko-at-optonline.net> Re: [NYLXS - HANGOUT] wget & mirrors
  70. 2008-09-30 Mark Simko <msimko-at-optonline.net> Re: [NYLXS - HANGOUT] wget & mirrors
  71. 2008-09-30 Matthew <mph-at-dorsai.org> Re: [NYLXS - HANGOUT] wget & mirrors
  72. 2008-09-30 From: "Paul Robert Marino" <prmarino1-at-gmail.com> Re: [NYLXS - HANGOUT] wget & mirrors
  73. 2008-09-30 From: "Paul Robert Marino" <prmarino1-at-gmail.com> Re: [NYLXS - HANGOUT] wget & mirrors
  74. 2008-09-30 From: "armando fonseca" <afonsec2-at-gmail.com> Re: [NYLXS - HANGOUT] Shana Tova
  75. 2008-09-30 Amy Coleman <acoleman-at-mrbrklyn.com> Re: [NYLXS - HANGOUT] Shana Tova

NYLXS are Do'ers and the first step of Doing is Joining! Join NYLXS and make a difference in your community today!