Topic: Declaring *this const
Author: oliva@dcc.unicamp.br (Alexandre Oliva)
Date: Wed, 28 Oct 1992 18:09:23 GMT Raw View
Is there any way to declare, in a member function, that the object it
will operate on, that is, *this, is const?
Alexandre Oliva
oliva@dcc.unicamp.br
Depto de Ciencia da Computacao
DCC - IMECC - UNICAMP
Campinas SP Brazil
Author: bs@alice.att.com (Bjarne Stroustrup)
Date: 29 Oct 92 02:27:55 GMT Raw View
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.