Article View: comp.std.c++
Article #7Re: Declaring *this const
From: Bjarne Stroustrup
Date: Thu, 29 Oct 1992 02:27
Date: Thu, 29 Oct 1992 02:27
15 lines
896 bytes
896 bytes
oliva@dcc.unicamp.br (Alexandre Oliva @ The Ohio State University Department of Computer and Information Science)writes
> Is there any way to declare, in a member function, that the object it
> will operate on, that is, *this, is const?
yes:
class X {
void f() const; // f()'s *this is const
void g(); // g()'s *this is non-const
};
See the ARM or any decent C++ textbook.
Technical Details
Message-ID:
<24035@alice.att.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!network.ucsd.edu!usc!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!att!allegra!alice!bsReferences:
<9210281609.AA02775@dcc.unicamp.br>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!network.ucsd.edu!usc!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!att!allegra!alice!bs From: bs@alice.att.com (Bjarne Stroustrup) Newsgroups: comp.std.c++ Subject: Re: Declaring *this const Message-ID: <24035@alice.att.com> Date: 29 Oct 92 02:27:55 GMT Article-I.D.: alice.24035 References: <9210281609.AA02775@dcc.unicamp.br> Organization: AT&T Bell Laboratories, Murray Hill NJ Lines: 15