cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
conditions in WHILE loop
conditions in WHILE loop
Jan 4, 2013 at 11:30pm UTC
Dzoni
(7)
Hi,
in while loop like this
class A* a;
while (a && a->something1==something2) {body}
when a=NULL what is correct:
1) i get error because i cant get "a->something"
2) loop always check 1st condition and if it is true then check 2nd 3rd... so it will work propraly
thx
Jan 4, 2013 at 11:32pm UTC
S G H
(2638)
Option 2) is the correct one.
'a' will be checked first. If it's not 0, other conditions are checked.
So, it is good to use it.
Jan 4, 2013 at 11:47pm UTC
Dzoni
(7)
thx bro :)
Topic archived. No new replies allowed.