samedi 23 février 2019

pointer list of pointer objects

I think my cList has some problem, but I dont know how to fix it. Am I doing it right?

course *a=new course(c);
list<course*> * cList = new list< course * > ;
(*cList).push_back(a);
enter image description here void add_course(map * > *> &DB, int semester, int id, course c){
course *a = new course(c);

map<int, map<int, list<course *> * > *>::iterator it1;
it1 = DB.find(id);
if(it1!= DB.end())
{
    map<int, list<course *> * >::iterator it2;
    map<int, list<course *> * > * temp;
    cout<<"oijnhbgh\n";
    temp = (DB.find(id))->second;
    if(temp == nullptr)
    {
      //(*temp).insert(pair<int, list<course *> *>(semester, nullptr));
        list<course *> * cList = new list<course *>;
        (*cList).push_back(a);
        (*cList).clear();
        (*cList).push_back(a);
        (*temp)[semester] = nullptr;
       // (pair<int, list<course *> *> (semester,cList));
    }else
    {
       //somecode
    }

}

Aucun commentaire:

Enregistrer un commentaire