for (int i(0); i < 10; ++i) { ... }
Has the int i(0) syntax inside the for loop initializer always been allowed in standard C++?
It compiles fine with g++ -std=c++98, but I don’t trust compilers when it comes to standard details.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here are the relevant parts of the syntax found in The C++ Programming Language, Appendix A:
So yes, the
for (int i(0); ...syntax has always been allowed in standard C++.