Mail Archives: djgpp/1997/08/11/16:03:31
From: | Erik Max Francis <max AT alcyone DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: A question about C++ language!
|
Date: | Fri, 08 Aug 1997 01:43:01 -0700
|
Organization: | Alcyone Systems
|
Lines: | 21
|
Message-ID: | <33EADC15.13552E3@alcyone.com>
|
NNTP-Posting-Host: | newton.alcyone.com
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
You wrote:
> What does "double g() const;" line in the following code mean? Is it
> different from the next line "double g();"? This is an example from a
> book called "Scientific and Engineering C++:
It means that the member function is constant, that is, guarantees not to
modify the state of the object.
That is, a const member function can only access the values of class
members (not set them), and can only call other const member functions.
Furthermore, if you have a const object (const C, const C &, or const C
*), then only the const member functions can be called.
--
Erik Max Francis, &tSftDotIotE / email / mailto:max AT alcyone DOT com
Alcyone Systems / web / http://www.alcyone.com/max/
San Jose, California, United States / icbm / 37 20 07 N 121 53 38 W
\
"Love is not love which alters / when it alteration finds."
/ William Shakespeare, _Sonnets_, 116
- Raw text -