知识库

C++语言开发示例:03. 类型转换

2025-02-01 20:23:38 李腾 1 次阅读

typecast.cpp

#include <iostream>

int main()
{
    using namespace std;
    int auks, bats, coots;

    auks = 19.99 + 11.99;
    bats = (int)19.99 + (int)11.99;
    coots = int(19.99) + int(11.99);
    cout << "auks = " << auks << ", bats = " << bats;
    cout << ", coots = " << coots << endl;

    char ch = 'Z';
    cout << "The code for " << ch << " is ";
    cout << int(ch) << endl;
    cout << "Yes, the code is ";
    cout << static_cast<int>(ch) << endl;
}
转载请注明转自www.hylab.cn,原文地址:C++语言开发示例:03. 类型转换

评论 (0)

登录后发表评论

暂无评论,快来发表第一条评论吧!