TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: JERRY COFFIN
from: THOMAS MAEDER
date: 1997-08-24 16:34:00
subject: fstream identifying mode

JC>  JC>     int mode() {
JC>  JC>         return mode_;
JC>  JC>     }
JC>  TM> Better declare this method const.
JC> Twouldn't hurt, but then again, I'm not sure I've ever seen a const
JC> stream, so I doubt it makes any real difference.  If you did somehow
JC> have a const stream, about ALL you'd be able to do with it would be
JC> its mode, and perhaps flags and such.  You obviously wouldn't be abl
JC> read/write it, and a stream you can't read or write seems awfully cl
JC> to useless at first glance.
If the stream is a member of a constant object (of of an object  whose
const  method  is  called),  you  are  only  allowed to call the const
methods of the stream.
But that's only an example. Declaring all  methods  const  that  don't
modify  the  state  of  the  object on which thy are applied is always
worth the effort in the long run. What  do  you  lose  declaring  them
const? Nothing.
Thomas
---
 þ MM 1.0 #0113 þ Nothing is so smiple that it can't get screwed up.
--- PCBoard (R) v15.22/M 25
---------------
* Origin: McMeier & Son BBS (2:301/138)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.