List and list elements, where are stored?

前端 未结 7 1608
粉色の甜心
粉色の甜心 2021-01-05 17:59

Given this piece of code:

#include 
(void) someFunction(void) {
    list  l;
    l.push_back(1);
}
  • Where are t
7条回答
  •  悲&欢浪女
    2021-01-05 18:57

    A return function is declared like this : list somefunc() {list L; return L; } .

    Check that values with list::iterator .

    Like this :

    #include 
    #include 
    using namespace std;
    
    
    list someReturnFunc(int listSize)
    {
        list myList;
    
        for (int g=0; g< listSize; g++)  myList.push_back(g);
    
        return myList;
    }
    
    int main ()
    {
        list yourList;
        list::iterator i;
    
        yourList = someReturnFunc(15);
    
        for(i=yourList.begin(); i != yourList.end(); ++i) cout << *i << " ";
    
        cout << endl;
    
        return 0;
    
    }
    

提交回复
热议问题