const member functions

D

Denver Dash

I've been having trouble with my news reader. Sorry if I posted this
twice...

Hi. I heard once that there is a way to allow a const member function to
alter the value of a member if the member is declared in some way. Can
someone tell me how to do that, or is this impossible?

For example:

class foo
{
specialdeclaration int index;
void bar() const
{
index = 0; \\ ok because index has been declared in a special way.
}
};

thanks,
denver.
 
R

Rolf Magnus

Denver said:
I've been having trouble with my news reader. Sorry if I posted this
twice...

Hi. I heard once that there is a way to allow a const member function
to
alter the value of a member if the member is declared in some way.
Can someone tell me how to do that, or is this impossible?

For example:

class foo
{
specialdeclaration int index;

Replace 'specialdeclaration' with 'mutable'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top