|
-
October 15th, 2002, 11:10 AM
#4
Re: If then assignment
Originally posted by billfor
1 bool SomeClass::SomeMethod(___)
2 {
3 boolean Flag;
4
5 if(!(Flag = myObeject.myMethod( inParam)))
6 {
7 FunctionGetSomeData(pIndex,Dvar),
8 FunctionWriteData(Dvar);
9 }
10 /* about 25 more lines of code below this */
.
35 return flag
36 }
Or, if the flag is used later in the "about 25 more lines of code below this", use the copy constructor. Else don't bother about flag;
1 bool SomeClass::SomeMethod(___)
2 {
3 boolean Flag(myObeject.myMethod(inParam));
4
5 if(Flag == false)
6 {
7 FunctionGetSomeData(pIndex,Dvar);
8 FunctionWriteData(Dvar);
9 }
10 /* about 25 more lines of code below this */
Has the benefit of not initailising flag first and then assigning.
By the way; I prefere always to compare for example "flag" to something (i.e. flag == false instead of !flag). Any oppinions anyone?
villemos.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|