"not an lvalue"
Peter Alexander
peter.alexander.au at gmail.com
Sun May 1 08:31:13 PDT 2011
On 1/05/11 2:53 PM, Dmitry Olshansky wrote:
> Ehm.. Well, first things first: you shouldn't use classes for
> lightweight & plain data things like vectors. There are structs for
> that. In general, structs are value-like objects living on the stack
> while classes are reference-like objects living on the heap. Your
> current code is going to allocate on GC heap new vector in every
> GetColumn and I suspect also when adding two vectors.
structs don't live on the stack. They live wherever they are told to. In
fact most structs will live in the heap as parts of class objects, or
other heap-allocated objects such as dynamic arrays or AAs. The stack is
for local variables and other things to do with the local scope.
While struct objects *can* go on the stack, it is false to say that
structs live on the stack and classes live on the heap. The type of an
object (value type or reference type) is orthogonal to its storage
location and the two should not be conflated.
More information about the Digitalmars-d-learn
mailing list