When do you use a struct instead of a class?
Posted
by
jkohlhepp
on Programmers
See other posts from Programmers
or by jkohlhepp
Published on 2011-07-12T16:22:41Z
Indexed on
2012/07/07
3:22 UTC
Read the original article
Hit count: 355
What are your rules of thumb for when to use structs vs. classes? I'm thinking of the C# definition of those terms but if your language has similar concepts I'd like to hear your opinion as well.
I tend to use classes for almost everything, and use structs only when something is very simplistic and should be a value type, such as a PhoneNumber or something like that. But this seems like a relatively minor use and I hope there are more interesting use cases.
© Programmers or respective owner