Re: Enum plus std::vector questions
PFRUIT CFruitRec::addfruit(PFRUIT pfruit)
// cannot convert from PFRUIT to const const FRUIT&
// pf = memcpy (&fruitarr[numfruit], pfruit, sizeof(pfruit));
// just want to return the current item to the caller...
Thanks for any further hints...
Please try to trim your posts. Due to the (regrettable) mixture of top
and bottom posting in these groups, the threads can get completely
messed up if you don't.
I assume that PFRUIT is FRUIT*, though you did not tell us that (come to
that you didn't say what FRUIT was either).
You have to decide whether you are storing FRUIT's or PFRUIT's in the
array. For a simple type like this I would always store the type itself:
FRUIT. I wouldn't use pointers at all for a type like FRUIT.
Then do like this:
const FRUIT& CFruitRec::addfruit(const FRUIT& fruit)
[You could make the return type FRUIT if you want a modifiable FRUIT.]
If this is all this method does, though, I would get rid of it. The
number of elements can always be obtained using fruitarr.size().
[Note that it a good idea, IMHO, to have a notation for members. It
makes a method much easier to read, because it tells you where you
should look for the declaration. I always use the "Microsoft m_"
notation, but some people just use a leading underscore.]
Visual C++ MVP