Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Extra libraries, Code snippets, applications etc. » C++ language problems and code snippets » Multiple statements in for loop
Re: Multiple statements in for loop [message #18439 is a reply to message #18436] Tue, 30 September 2008 21:01 Go to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

I'm ashamed that I missed so obvious solution Embarassed Probably because I ussualy declare only 1 variable per line if I initialize them.

What if we extend this problem a bit? Twisted Evil
Let's say, one would like to have there two variables of different type. Then it's impossible to write
for(bool b=true,int i=0;...;...){}
I tried this, but it seems that anything after "bool" is handled as declaration of bool.

Quote:

Anyway allocating 2+ variables in for-init can often lead to less readable source, so use with caution. I think it's better to avoid it whenever possible.


Yes, I'm aware of that Smile I was just playing with this idea before I found the right way to do it using just one variable.

Anyway, thanks for quick response Smile

Edit: Oups I've missed that mr_ped already thought about the two types case... Embarassed sorry

[Updated on: Tue, 30 September 2008 21:02]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Previous Topic: explanation of c++ typedef line
Next Topic: I don't get some aspects of STL ... [pointless rant]
Goto Forum:
  


Current Time: Mon May 13 16:22:01 CEST 2024

Total time taken to generate the page: 0.01667 seconds