[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Declarations in a for loop

From: Eljay Love-Jensen
Subject: Re: Declarations in a for loop
Date: Wed, 18 May 2005 11:06:23 -0500

Hi Fred,

>However, if I declare index and doublesIter before the for, then all works 
>fine.  Is that a bug?

Nope, not a bug.  What you have here is a case of bad C++ code.

int x, y; // This is good.

int x; std::vector<double>::iterator y; // This is good.

std::vector<double>::iterator x, y; // This is good.

int x, std::vector<double>::iterator y; // This is not good.

You can't put #2 in a for-loop initialization expression (since it's two 

#1 and #3 won't do what you want.

#4 isn't C++, whether inside or outside of a for-loop initialization 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]