Mail Archives: djgpp/1997/08/04/15:34:04
in general 'const' methods are declared and defined using
the keyword 'const' after the arguments list, just like in
'double g() const' you posted.
const functions (methods) are not allowed to modify values
of object's data members, and may only call const methods.
however, i am not sure how the ambiguity between the two
g() methods ('const' and non-const) is resolved if you do
this -
int main()
{
B b;
cout << b.g() << endl;
return 0;
}
??
Tianmiao Hu Family (thu AT mailhost DOT tcs DOT tulane DOT edu) wrote:
: Hello,
:
: 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++:
: An Introduction with Advanced Techniques and Examples". I have tried
: to compile it under DJGPP and it passed. I don't understand why "const"
: can appear after "g()"?
:
:
: class B {
: double g() const;
: double g();
: double g(int);
: void h();
: };
:
: Thank you for your great help!
:
: Tianmiao Hu
:
--
amit barak
- Raw text -