Re: Declarations in a for loop

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

 



El Miércoles, 18 de Mayo de 2005 17:56, Fred Labrosse escribió:
> All,
>
> The following doesn't compile (with different messages depending on the
> order in which I declare things:
>
> #include <vector>
>
> main()
> {
>    std::vector<double> doubles;
>    double aDouble;
>
>    for (int index = 0,
>            std::vector<double>::iterator doublesIter = doubles.begin();
>         doublesIter != doubles.end();
>         ++doublesIter, ++index)
>    {
>       if (aDouble == *doublesIter)
>          return(index);
>    }
> }
>
> However, if I declare index and doublesIter before the for, then all
> works fine.  Is that a bug?
>
> Fred

As far as I know if you declare several variables in the so-called 
init-statement they have to share the type.

Regards



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux