"Ishira" <is***********@yahoo.com> wrote in message
news:59**************************@posting.google.c om...
Hello,
Please help.
I am seriously at my wits end. Just when I feel I have completely
understood copy contructor, I am stumped yet again.
I have a class which has a CARRAY of objects. I am trying to write a
copy constructor for the class and it's simply havoc! The array
variable is private to the class and simply contains objects without
dynamic variables.So no issue there. Just the very copying of CArray
is giving me problems.
Maybe some code on how you would handle it will help trmedously.
Kindly throw some light on the matter.
Thank you.
Ishi
You should be using std::vector not CArray. At least you should if you want
to post to this group, since std::vector is a standard part of the C++
language, and CArray only exists in MFC. std::vector is also much better
designed than CArray, there is no problem copying std::vector objects.
#include <vector>
class B
{
...
};
class A
{
private:
std::vector<B> vec;
};
class A does not need a copy constructor, std::vector is well enough
designed that A will copy correctly with the compiler generated copy
constructor. That is not something that is true of CArray (I believe).
Time to learn some real C++, and leave MFC collection classes behind.
john