list<Gas_station> lst( 0,Gas_station() ); // Creates list
for( int counter=0 ; counter<3 ; counter++ )
{
Gas_station::Gas_station();//default constructor
Gas_station Station1;//creat an object
lst.push_front(Station1);//pushing it to the front of the list
// inserting the data to members
}
list<Gas_station> lst; // Creates list
for( int counter=0 ; counter<3 ; counter++ )
{
Gas_station Station1;//creat an object
lst.push_front(Station1);//pushing it to the front of the list
// inserting the data to members
}
no secrets there
EDIT: Note that 'push_front' takes a copy hence you have to set Station1 properly before you 'push_front'. Or you manipulate lst.front() afterwards.