How do i lock a variable in a class
View Single Post
04-20-2008, 09:11 PM
Join Date: Apr 2008
Originally Posted by
the return is used for reading, you asked about changing it's value?
Well, you can't 'lock' a variable to read only inside a class.
It is supposed that a class is a totally separate entity and you are the one who read/write class's properties unless you don't trust yourself :)
Well i do trust myself, but i just see it as a better solution to be able to 'lock' a variable so only the class and not the instance can give the variable a value.
It would decrease the use of return in a class and you would not need to assign a new variable outside the class to hold the value.
View Public Profile
Send a private message to Durux
Find More Posts by Durux