Nick Sabalausky Wrote: > "Jerry Quinn" <[email protected]> wrote in message > news:[email protected]... > > > > Use a class when you have things that make sense to share, and use structs > > for when it makes more sense to have distinct copies. > > > > Couldn't that rule conflict with cases where you'd want distinct copies but > need features of classes that aren't available for structs (like > inheritance)?
However, with reference semantics, you have no way to achieve objects laid out in a contiguous array, unless I'm missing something. If you want inheritance, copy semantics are an issue. For example, if you have struct A : B, and an array of B, you can't put an A in it, since there's not enough space for an A (unless A adds 0 storage). If you have an array of A, inheritance isn't really buying you anything over having a B as the first member of A. Any place where you'd want to use A as a B, you can get to the member B struct directly.
