Go back to Richel Bilderbeek's homepage.

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

 

 

 

 

 

(C++) RangeForExample1

 

Technical facts

 

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./CppRangeForExample1/CppRangeForExample1.pro

 

QT       += core
QT       -= gui
CONFIG   += console
CONFIG   -= app_bundle
TEMPLATE = app
QMAKE_CXXFLAGS += -std=c++11 -Wall -Wextra -Weffc++ -Werror
SOURCES += main.cpp

 

 

 

 

 

./CppRangeForExample1/main.cpp

 

#include <iostream>
#include <vector>

int main()
{
  std::vector<int> v = { 1,2,3,4,5,6,7,8,9 };
  for (int& i: v)
  {
    i*=i;
  }
  for (const int& i: v)
  {
    std::cout << i << ' ';
  }
    std::cout << std::endl;
}

/* Screen output:

1 4 9 16 25 36 49 64 81
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