Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) IteratorExample1

 

Technical facts

 

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./CppIteratorExample1/CppIteratorExample1.pro

 

TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
QMAKE_CXXFLAGS += -Wall -Wextra -Weffc++ -Werror
SOURCES += main.cpp

 

 

 

 

 

./CppIteratorExample1/main.cpp

 

#include <iostream>
#include <list>

int main()
{
  std::list<int> my_list;
  my_list.push_back( 1);
  my_list.push_back( 4);
  my_list.push_back( 9);
  my_list.push_back(16);
  my_list.push_back(25);
  my_list.push_back(36);
  my_list.push_back(49);

  //Display the list (not preferred)
  typedef std::list<int>::const_iterator Iterator;
  const Iterator j = my_list.end();
  for (Iterator i = my_list.begin(); i!=j; ++i)
  {
    std::cout << *i << '\n';
  }
}

/* Screen output:

1
4
9
16
25
36
49
Press <RETURN> to close this window...

*/

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml