By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,797 Members | 1,794 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,797 IT Pros & Developers. It's quick & easy.

CARRAY problem with ADD

P: n/a
Here is a snippet of my program. It is really intresting...


Class CobjA has a private CARRAY memeber m_Arr of objects CobjB.

Class CobjB is a class with an int data variable called pWidth. CobjB
has a copy and an assignment constructor defined.

I am trying to add a CobjB to the private CARRAY member of CobjA.

Since I cannot access the m_Arr directly I have a function called

AddCobjBToArr(CObjB obj) defined in class CobjA


I get a heap pointer error when I do this

CobjA* A=new CobjA();


I am honestly puzzled! Please help.
class CobjB: public CObject

// Copy Constructor
CobjB(const CobjB &b);
const CobjB & operator= (const CobjB & b);

int pWidth;

CobjB::CobjB(const CobjB& w)

const CobjB& CobjB::operator= (const CobjB& w)
return *this;


class CobjA: public CObject

CArray<CobjB,CobjB&> m_Arr;
void AddCobjBToArr(CobjB b);

void CobjA::AddCobjBToArr(CobjB b)
m_Arr.Add(b); //Add CobjB to the private array

In the main function

CobjA *objA=new CobjA();

Why does this result in a Debug Assertion Failed
Jul 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.