Click here to Skip to main content
15,912,897 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Locking a window Pin
fjdiewornncalwe14-Oct-10 13:47
professionalfjdiewornncalwe14-Oct-10 13:47 
Questiontrue/false statements in if clause Pin
sadas232341s13-Oct-10 7:55
sadas232341s13-Oct-10 7:55 
AnswerRe: true/false statements in if clause Pin
Maximilien13-Oct-10 8:11
Maximilien13-Oct-10 8:11 
AnswerRe: true/false statements in if clause Pin
Richard MacCutchan13-Oct-10 8:12
mveRichard MacCutchan13-Oct-10 8:12 
AnswerRe: true/false statements in if clause Pin
David Crow13-Oct-10 8:12
David Crow13-Oct-10 8:12 
AnswerRe: true/false statements in if clause Pin
Code-o-mat13-Oct-10 8:18
Code-o-mat13-Oct-10 8:18 
GeneralRe: true/false statements in if clause Pin
anonymouscodder13-Oct-10 12:48
anonymouscodder13-Oct-10 12:48 
GeneralRe: true/false statements in if clause Pin
Code-o-mat13-Oct-10 22:05
Code-o-mat13-Oct-10 22:05 
As Richard said, it is a matter of style really. That form can also be very easily readable with well named variables, e.g:
if (noMoreItemsLeft) EndOfItems();
looks quite obvious when you read through the code, but
if (!ptrToNextItem) EndOfItems();
you have to 'analyze' this, if not ptrToNextItem, this means, if ptrToNextItem is zero, then...
I also don't like situations like this:
class AClass
{
public:
  int  Integer;
  bool Bool;

  AClass(int i, bool b):Integer(i),Bool(b) {}
  operator bool() const { return Bool; }
  AClass &operator =(int i) { Integer = i; return *this; }
};
...
AClass A(0, true);
if (A) A = 3;  //So here A's bool operator will be used and since it is true, A = 3 will run, however, A's
               //integer value is 0, if we were to test for that, A = 3 wouldn't run. Ok, in this example
               //it is quite obvious but imagine a big class with loads of operators and methods and this 
               //<code>if</code> embedded in a "busy" part of the code, "far far" away from the
               //declaration of the class. If you were to "scan" through the code and see this you could
               //think: 'what this does is making A's value 3 when A isn't 0, A is likely to be an
               //integer'...
...

> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

GeneralRe: true/false statements in if clause Pin
Aescleal13-Oct-10 23:06
Aescleal13-Oct-10 23:06 
GeneralRe: true/false statements in if clause Pin
Code-o-mat13-Oct-10 23:15
Code-o-mat13-Oct-10 23:15 
AnswerRe: true/false statements in if clause Pin
Luc Pattyn13-Oct-10 8:31
sitebuilderLuc Pattyn13-Oct-10 8:31 
GeneralRe: true/false statements in if clause Pin
CPallini13-Oct-10 9:19
mveCPallini13-Oct-10 9:19 
GeneralRe: true/false statements in if clause Pin
Niklas L14-Oct-10 2:44
Niklas L14-Oct-10 2:44 
GeneralRe: true/false statements in if clause Pin
PravinSingh14-Oct-10 5:49
PravinSingh14-Oct-10 5:49 
GeneralRe: true/false statements in if clause Pin
Niklas L14-Oct-10 6:33
Niklas L14-Oct-10 6:33 
QuestionRe: true/false statements in if clause Pin
PravinSingh14-Oct-10 21:26
PravinSingh14-Oct-10 21:26 
AnswerRe: true/false statements in if clause Pin
Niklas L15-Oct-10 7:42
Niklas L15-Oct-10 7:42 
AnswerRe: true/false statements in if clause Pin
fjdiewornncalwe13-Oct-10 8:33
professionalfjdiewornncalwe13-Oct-10 8:33 
AnswerRe: true/false statements in if clause Pin
Aescleal13-Oct-10 11:21
Aescleal13-Oct-10 11:21 
QuestionCInternetSession: https certificate problem Pin
msn9213-Oct-10 6:05
msn9213-Oct-10 6:05 
AnswerRe: CInternetSession: https certificate problem Pin
Code-o-mat13-Oct-10 6:19
Code-o-mat13-Oct-10 6:19 
GeneralRe: CInternetSession: https certificate problem Pin
msn9214-Oct-10 4:49
msn9214-Oct-10 4:49 
GeneralRe: CInternetSession: https certificate problem Pin
Code-o-mat14-Oct-10 5:21
Code-o-mat14-Oct-10 5:21 
QuestionRemove Maximize Pin
john563213-Oct-10 5:20
john563213-Oct-10 5:20 
AnswerRe: Remove Maximize Pin
Aescleal13-Oct-10 5:43
Aescleal13-Oct-10 5:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.