Advertisement

Need help with STL lists

Started by March 10, 2003 07:02 PM
1 comment, last by g_hempstock 21 years, 8 months ago
I''m using the STL list type in a program, and I need help with accessing the member functions of a class that makes up the list. For example:
  
#include <list>
#include <string>
#include <iostream>

using namespace std;

int main()
{
    list<string> nums;
    list<string>::iterator iter;
    
    nums.push_front("George ");
    nums.push_front("of ");
    nums.push_front("the ");
    nums.push_front("jungle");
    
    for (iter = nums.begin(); iter != nums.end(); iter++)
    {
        cout << *iter.length() << " "; //is this the correct way to access the member function?

    }

    return (0);
}
  
''''I can imagine a world without hate, a world without fear, a world without war. And I can imagine us attacking that world, because they would never expect it.'''' -Jack Handy
_______________________________________________________________________________________''I can imagine a world without hate, a world without fear, a world without war. And I can imagine us attacking that world, because they would never expect it.'' -Jack Handy
use (*iter).length() or iter->length() .

But... but that''s what HITLER would say!!
Advertisement
Thank you so much!

''''I can imagine a world without hate, a world without fear, a world without war. And I can imagine us attacking that world, because they would never expect it.'''' -Jack Handy
_______________________________________________________________________________________''I can imagine a world without hate, a world without fear, a world without war. And I can imagine us attacking that world, because they would never expect it.'' -Jack Handy

This topic is closed to new replies.

Advertisement