指针对象的指针列表

时间:2019-02-23 08:04:22

标签: list c++11 pointers

我认为我的cList有问题,但是我不知道如何解决它。我做对了吗?

course *a=new course(c);
list<course*> * cList = new list< course * > ;
(*cList).push_back(a);

enter image description here

void add_course(map<int, map<int, list<course *> * > *> &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
    }

}

0 个答案:

没有答案