Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main() {
- std::size_t a = 1;
- int b = -a; // obviously, b <= a
- std::cout << "a = " << a << ", b = " << b << std::endl;
- std::cout << "try without cast) ";
- if (b <= a)
- std::cout << "b <= a" << std::endl;
- else
- std::cout << "b > a" << std::endl;
- std::cout << "try with cast) ";
- if (b <= static_cast<int>(a))
- std::cout << "b <= a" << std::endl;
- else
- std::cout << "b > a" << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement