mfc - CList's AddTail() assertion error -
i trying create double-dimensional list in mfc in order save , work int , cstring data. so, i've tried this:
#include "a.h" //a.cpp a::a() { } a::~a() { } //********************** #pragma once // a.h class a: public cobject { public: a(); virtual ~a(); int id; cstring label; }; //********************** #include "a.h" #pragma once // b.h class b : public cobject { public: b(); virtual ~b(); int anotherid; cstring anotherlabel; clist<a*, a*&> * alist; clist<cstring, cstring&> * testlist; }; //note: b.cpp pretty same a.cpp //********************* //c.cpp void c::foo() { b * b = new b; * = new a; a->id = 1; a->label = l"something"; b->alist->addtail(a); //assertion error! cstring aux = l"another thing"; b->testlist->addtail(aux); //assertion error! }
here's problem: when try use addlist() method, receive error "access violation reading location". first thought problem related cobject derived classes, not sure if real problem. i've tried new , delete overloading, problem became worst. ideas?
both list elements declared pointers, you'll need either allocate them or declare them as
clist<a*, a*&> alist; // without "*" clist<cstring, cstring&> testlist; // without "*"
Comments
Post a Comment