[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



Hej Kristian.

Kristian Nørgaard <sslug@sslug> wrote on 17-05-2006 14:50:14:

> Kan jeg oprette og initialisere en struct uden at oprette en (navngiven) 

>   variabel, når structen blot skal anvendes direkte isom 
funktionsargument?
> 
> Jeg har:
> -------------
> typedef struct{ int id; int value; } valpair;
> list<valpair> mylist;
> --------------
> 
> 
> Hvis jeg blot skal indsætte et 'valpair' synes jeg
> det er overkill at skulle:
> -----------------
> struct valpair tmpvalpair;
> tmpvalpair.id = 7;
> tmpvalpair.value = 47;
> mylist.push_back( tmpvalpair )
> -----------------
> 
> 
> Kan man gøre noget a la:
> ------------------
> mylist.push_back( { 7, 47 } );
> 
> eller
> 
> mylist.push_back( { id=7, value=47 } );


noget i stil med:

list<pair<int, int> > valpair;
valpair.push_back(make_pair(7, 47));



Venlig hilsen / Best regards

Nils Åke Ljunggren
Senior Developer
Mobile +45 2613 9966
sslug@sslug

IntraVision ApS 
Lyngsø Alle 3,  2970 Hørsholm,  Denmark
Office: +45 7023 2340
Fax: +45 7023 2349
www.intravision.dk



 
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] *