标题:有人能否帮我解释一下这个程序的运行结果?谢谢~~~~
取消只看楼主
莫一阳
Rank: 1
等 级:新手上路
帖 子:38
专家分:6
注 册:2011-4-27
结帖率:78.57%
已结贴  问题点数:9 回复次数:0 
有人能否帮我解释一下这个程序的运行结果?谢谢~~~~

#include<iostream>
using namespace std;

union u_type
{
    int num;
    char ch[2];
    void set_num(int anint);
    void showchars();
};

void u_type::set_num(int anint)
{
    num=anint;
}

void u_type::showchars()
{
    cout<<ch[0]<<' '<<ch[1]<<endl;
}

int main()
{
    u_type aunion;
    aunion.set_num(9798);
    aunion.showchars();
    return 0;
}

运行结果:
       F &
2011-06-21 21:54



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-343595-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.123976 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved