Q: How can I make a class act like a value type (such as struct)

Carlos Santander csantander619 at gmail.com
Sun May 27 14:21:55 PDT 2007


Myron Alexander escribió:
> 
> The problem with this struct is that the name, and value fields are 
> public and I want them private so the user is forced through the opCall. 
> My reason for this is that I want all the validations done on 
> initialization instead of having to be done whenever I use the values. 
> (These validations are not in the above code).
> 
> The only way to make the fields private is to have a class so I would 
> like to build my class to work as a value object in the same way that 
> structs do but with information hiding.
> 

You can use "private" et al. with structs too.

-- 
Carlos Santander Bernal


More information about the Digitalmars-d-learn mailing list