Read only and / or write only class members

A

A

I'd like to have a class where a certain properties are read only to the
outside class but read/write within the class. Obviously "const" won't do at
least not how I usually use it. Perhaps something based on "friend"?

I use C++ builder so perhaps "__property" could be used for this purpose
(I've used it for VCL derived classes but I'm not sure if it can be used for
classes that don't derive from VCL). That would be the easiest way probably.
 
I

Ian Collins

I'd like to have a class where a certain properties are read only to the
outside class but read/write within the class. Obviously "const" won't do at
least not how I usually use it. Perhaps something based on "friend"?

Make them private and provide a const accessor member function.
 

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,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top