How to embed CList<CMyClass, CMyClass&> as a member of CMyClass?

I am in the process of converting a std::vector based list to a CList.  Problem is that I have a class that needs to define a member that is a list of its own type (recursive).  Here's the pseudo code:

class CMyClass
{
public:
  CList<CMyClass, CMyClass&> m_cMyList;
};

  For the record, I can do this with std::vector, but I get error C2079: 'data' uses undefined class 'CMyClass' when I use CList.

  Now, I know that I could do this:

class CMyClass
{
public:
  CList<CMyClass*, CMyClass*&> m_cMyList;
};

  but I would have a TON of memory management code to write, as this is a very large project that this concept is heavily embedded in.

  Am I totally out of luck here, or is there some magical workaround that will get past the compiler errors?  Using Visual C++ 6.0 SP3.

  The reason I'm doing this is because of the problems we've been having with std::vector.  CList has been much more reliable for us, and we want all of our code to use that.

  Any and all help is much appreciated!!!  Thanks in advance!

Doug
DouglasHoltAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DouglasHoltAuthor Commented:
Hi all,

  I should have figured this out quicker, but anyway, here's the solution:

  std::vector is much closer to CArray than CList.  CArray doesn't have the problem I mentioned above.

  So, use CArray to replace std::vector, and it will work fine.

Doug
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.