u1201.cpp
#include <iostream> int main() { char a = 'a'; short b = 5; int c = 156; long d = 5; float e = 9.8; double f = 12.5; if (b) { std::cout << "short => bool, " << typeid(b).name() << std::endl; } std::cout << "char => int, " << (a / b) << ", " << typeid(a / b).name() << std::endl; std::cout << "short => long, " << (b * d) << ", " << typeid(b * d).name() << std::endl; std::cout << "int => float, " << (c / e) << ", " << typeid(c / e).name() << std::endl; std::cout << "double => int, " << (c = f) << ", " << typeid(c).name() << std::endl; return 0; } /* Kaiching Chang u1201.cpp 2014-02 */
u1202.cpp
#include <iostream> int main() { char a = 'a'; int b = 97; std::cout << a << std::endl; std::cout << b << std::endl; std::cout << static_cast<char>(b) << std::endl; std::cout << static_cast<int>(a) << std::endl; return 0; } /* Kaiching Chang u1202.cpp 2014-02 */
the end
沒有留言:
張貼留言