30.9 Final Note

I l @ ve RuBoard

Just when you think you've discovered all the things C++ can do to you ”think again. There are still more surprises in store.

Question 30-1: Why does Example 30-1 think everything is two? (This inspired the final note.)

Example 30-1. not2/not2.cpp
 #include <iostream> int main(  ) {     int number;     std::cout << "Enter a number: ";     std::cin >> number;     if (number =! 2)          std::cout << "Number is not two\n";     else         std::cout << "Number is two\n";     return (0); } 
I l @ ve RuBoard


Practical C++ Programming
Practical C Programming, 3rd Edition
ISBN: 1565923065
EAN: 2147483647
Year: 2003
Pages: 364

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net