On Mon, 8 Jun 2015 15:08:12 -0700 (PDT), fl <
rxj...@gmail.com> wrote:
>Hi,
>
>When I read a post on-line about self-assignment, I do not understand one
>line:
>
> delete[] data;
>
>
>My question here is not directly related to self-assignment, but about the
>function of *data and n in the class array. What use are *data and n?
>
>Whether they are meant to an array length n, beginning address is by a
>pointer data?
>
>Please help me on the function:
>
>array &array::operator =(const array &rhs)
>
>
>
>Thanks,
>
>
>..................................
>class array {
> ...
> int *data;
> size_t n;
>};
I would say above that
"data" is space for a pointer to int, and n is the size of the obj a
can point
i would say it is + useful something as
class array {
...
unsigned *d;
unsigned dlen;
unsigned dsiz;
};
"d" is space for a pointer to unsigned int, "dlen" is the number of
unsigned elements, obj pointed from"d" contain,
dsiz is the number of unsigned "d" can access [the memory "d" can use]
for minimize malloc() / free() use