[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] [c++] midlertidig / flygtig struct



Hvad med

------------------------------
#include <iostream>
#include <list>

using namespace std;

struct valpair {
        int id;
        int value;
        valpair(int i, int v) : id(i), value(v) {}
};

int main (int argc, char *argv[])
{
        list<valpair> mylist;
        mylist.push_back(valpair(7, 47));
        mylist.push_front(valpair(8, 13));
        while (! mylist.empty()) {
                valpair &vp = mylist.front();
                cout << vp.id << " = " << vp.value << endl;
                mylist.pop_front();
        }
}
-------------------------------

Det sparer tastetryk, men der oprettes dog stadigvæk temporære objekter i baggrunden,
HC



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2006-06-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *