Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
auto is a keyword that has different meanings, depending on the standard used:
auto in the C++98 standard
auto as described in the ISO/IEC 14882:2003 C++ Standard is a keyword to specify that a locally declared variable is destroyed at the end of its scope. In other words: to specify to do, what already will be done. Never write auto [1].
int main() |
Note that when using the Qt Creator IDE, the above code already results in the compile warning 'auto' will change meaning in C++0x; please remove it.
auto in the C++0x standard
In the C++0x Standard, auto is useful to let the compiler determine a variable's data type In the example below, 'i' is inferred to be of type std::vector<int>::const_iterator.
#include <iostream> |
Technical note: the code shown is compiled successfully using the G++ 4.4.5 compiler, which is supplied with the Qt Creator 2.0.0 IDE.
Note for Qt Creator users
Add the following line to your Qt project file to work with C++0x:
QMAKE_CXXFLAGS += -std=c++0x |
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.