#include <iostream> int i = 20; int main() { int i = 10; int i = 20; // only possible if your compiler/compiler-mode is "stupid". for (int i = 0; i < 5; ++i) { std::cout << "loop i = " << i << std::endl; } std::cout << "i = " << i << std::endl; }
Standard input is empty
prog.cpp: In function ‘int main()’: prog.cpp:7:13: error: redeclaration of ‘int i’ int i = 20; // only possible if your compiler/compiler-mode is "stupid". ^ prog.cpp:6:13: error: ‘int i’ previously declared here int i = 10; ^
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!