STL list error

Wilson Wilson@WSSPL.com
Mon Oct 22 01:13:00 GMT 2001


> Hi There,
> Check the following sample code. Here I expect the second unique() call to
> the list should make the list unique after the addition of 20 again. But
its
> not happening. Can you provide the reason for this.
> 
> int main( void )
> {
>     list< int > myList;
> 
>     myList.push_back( 10 );
>     myList.push_back( 10 );
>     myList.push_back( 20 );
>     myList.push_back( 30 );
>     myList.push_back( 40 );
> 
>     cout << "Size of list = " << myList.size() << endl;
>     myList.unique();
>     cout << "Size of list = " << myList.size() << endl;
>     myList.push_back( 20 );
>     myList.unique();
>     cout << "Size of list = " << myList.size() << endl;
> 
> }
> 
> Regards
> Wilson
> 

-- 
Orion Montoya, FSF Office Staff
Free Software Foundation     |  Phone: +1-617-542-5942
59 Temple Place, Suite 330   |  Fax:   +1-617-542-2652
Boston, MA 02111-1307  USA   |  Web:   http://www.gnu.org




More information about the Gcc-help mailing list