CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Quiz

Threaded View

  1. #4
    Join Date
    May 1999
    Location
    CT
    Posts
    75
    The "Even" in the second if statement points to the function bool Even( int ); which always exist so is always true.

    The reason for this is that the scope for the variable "bool Even" is inside of the first if statement. It will only be instantiated and then destroyed when and if the number to be tested is even.

    So by the time it gets to the second if statement, the "bool Even" variable doesn't exist anymore.

    And if the number to be tested is false, well "bool Even" variable would never have been created.
    Last edited by smakadia; April 22nd, 2004 at 12:08 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured