Hello there! I am currently coding the base of a future program. However, after compiling the code(no errors), there is a forced brake point. The Error says: Debug Assertion Failure, Expression: List iterations incompatible.
Please bare with me, code is not exactly small:
_medcontainer.h
medutility.hCode:#ifndef _MEDCONTAINER_H #define _MEDCONTAINER_H #include <cstring> enum TYPE{NAME, DESC, ID, AMOUNT, ALL}; class _medContainer { public: ////////////////////////////////////////////////////////////////////////// //CONSTRUCTOR(S) AND DESTRUCTOR(S) _medContainer(); _medContainer(char *name, char *desc, char* id, char* amount, TYPE type = NAME); virtual ~_medContainer(); ////////////////////////////////////////////////////////////////////////// //ACCESSOR FUNCTIONS void SetCounter(unsigned int val) { m_Counter = val; } void SetName(char* val) { m_name = val; } void Setdesc(char* val) { m_desc = val; } void SetId(char* val) { m_id = val; } void SetAmount(char* val) { m_amount = val; } void SetSortString(char* compareString){compare = compareString;} char* Getname() { return m_name; } char* Getdesc() { return m_desc; } char* GetCompare() { return compare; } char* Getid() { return m_id; } char* Getamount() { return m_amount; } unsigned int GetCounter() { return m_Counter; } ////////////////////////////////////////////////////////////////////////// //OPERATOR OVERLOADING _medContainer& operator=(const _medContainer& other); friend bool operator<(const _medContainer& o1,const _medContainer& o2); friend bool operator>(const _medContainer& o1,const _medContainer& o2); friend bool operator==(const _medContainer& o1,const _medContainer& o2); friend bool operator!=(const _medContainer& o1,const _medContainer& o2); protected: private: unsigned int m_Counter; //MEDCONTAINER COUNTER char* m_name; //NAME OF THE OBJECT char* m_desc; //DESCRIPTION OF PARTICULAR OBJECT char* compare; //STRING THAT WILL BE USED TO COMPRE IN SORT() char* m_id; //IDENTIFICATION OF OBJECT char* m_amount; //AMOUNT OF PARTICULAR OBJECT char m_DlastModified[9];//DAY IN WHICH IT WAS LAST MODIFIED char m_TlastModified[9];//TIME IN WHICH IT WAS LAST MODIFIED }; #endif // _MEDCONTAINER_H
All the function definitions are taken care of.... When I do this is main()Code:#ifndef MEDUTILITY_H #define MEDUTILITY_H #include "_medContainer.h" //INCLUDE MEDCONTAINER CLASS #include <list> //LIST CONTAINERS #include <fstream> //IN ORDER TO LOAD/SAVE SETTINGS AND LISTS using namespace std; typedef list<_medContainer> medList; //DEFINE A STANDARD LIST KEYWORD typedef list<_medContainer*> medSearchResultList; //LIST THAT LINKS TO SEPERATE ELEMENTS OF A LISTS typedef _medContainer* _medConPointer; ////////////////////////////////////////////////////////////////////////// //STRUCTURE USED TO STORE SEARCH RESULTS struct SearchResults { medSearchResultList Result; unsigned int ResultsFound; }; ////////////////////////////////////////////////////////////////////////// //GENERIC UTILITY FUNCTIONS medList SortByType(medList &UnsortedList, TYPE SortBy); //USED TO SORT A MEDLIST BY TYPE medSearchResultList* FindString(medList &SearchedList, char *keyword, TYPE FindWhere); char* ReturnVariableString(_medContainer &Container, TYPE type); ////////////////////////////////////////////////////////////////////////// //SingleList CLASS - FACILITATES LIST MANIPULATION class SingleListClass { public: medList *List; ////////////////////////////////////////////////////////////////////////// //CONSTRUCTOR(S) AND DESTRUCTOR(S) //IN CASE FOR TEMPORARY CREATION SingleListClass(); //ALLOWS TO CREAT A LIST WHILE DECLARING THE FIRTS ELEMENT SingleListClass(char *name, char *desc, char *id, char *amount); //DISMISS A SingleList OBJECT ~SingleListClass(); ////////////////////////////////////////////////////////////////////////// //DEDICATED FUNCTIONS medList *GetList() { return List; }; bool Add(char *name, char *desc, char *id, char *amount); void Add(_medContainer& AddElement); void Add(); medSearchResultList* Find(char *keyword, TYPE type); int MaxSize(){return (int)List->max_size();} medList Sort(TYPE Sortby); }; #endif
It compiles all right...however when I execute it gives me the error previously mentioned at this place in the code:Code:#include "_medContainer.h" #include "medUtility.h" #include <iostream> void ShowAll(medList &ReferenceList); SingleListClass *mynewList = new SingleListClass ("Test", "Test", "341873", "1"); medSearchResultList *Results = new medSearchResultList; int main(int argc, char *argv[]) { mynewList->Add(); cout<<"BEFORE: "<<endl; ShowAll(*mynewList->GetList()); medList::iterator *it = &mynewList->GetList()->begin(); while( *it != mynewList->GetList()->end()) { Results->push_back(&(**it)); *it++; } system("PAUSE"); cout<<"MODIFIED THROUGH POINTER LIST CLASS"<<endl; ShowAll(*mynewList->GetList()); system("PAUSE"); return(0); } void ShowAll(medList &ReferenceList) { medList::iterator it = ReferenceList.begin(); while(it != ReferenceList.end()) { cout<<"NAME: \n\t"<<it->Getname()<<endl; cout<<"DESC: \n\t"<<it->Getdesc()<<endl; cout<<"ID: \n\t"<<it->Getid()<<endl; cout<<"AMOUNT: \n\t"<<it->Getamount()<<endl; it++; } }
I know that I could use the STL string class but I am experimenting for the moment. Other suggestions are welcomed!Code:while( *it != mynewList->GetList()->end()) { Results->push_back(&(**it)); *it++; }
Thanks in advance for the people who dare to help me!

