| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 732 人关注过本帖
标题:万分火急的求教,会的进C++简单运行结果题
取消只看楼主 加入收藏
yzhp518
Rank: 1
来 自:广州
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-3-26
收藏
 问题点数:0 回复次数:2 
万分火急的求教,会的进C++简单运行结果题
1、    写出下列程序的结果
#include <iostream.h>
Class Myclass
{
    Public:
            Myclass(int a){x=a;}
            Void fun1(){x++;}
            Void fun2(){x+=2;}
            Void fun3(){x+=3;}
            Void print(){cout<<”x=”<<x<<endl;}
    Private:
            Int x;
};
Void main()
{
    Myclass my(8);
    Void(Myclass::*pf)();
    my.print();
    pf=Myclass::fun2;
    (my.*pf)();
    my.print();
    pf=Myclass::fun3;
    (my.*pf)();
    my.print();
}
运行结果为:


2、写出下列程序的运行结果。
#include<iostream.h>
int Div(int x,int y)
{
if(y= =0)
 throw y;
retrun x/y;
}
viod main()
{
try
{
cout<<"7/3="<<Div(7,3)<<endl;
cout<<"9/0="<<Div(9,0)<<endl;
cout<<"8/4=""<<Div(8,4)<<endl;
}
catch(int)
{
cout<<"Exception of dividing zero. "<<endl;
}
cout<<"It is OK."<<endl;
}

运行结果为:
搜索更多相关主题的帖子: Void 火急 Myclass int 
2008-03-26 12:49
yzhp518
Rank: 1
来 自:广州
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-3-26
收藏
得分:0 
哪位会的前辈帮帮忙哈,谢谢了
2008-03-26 13:38
yzhp518
Rank: 1
来 自:广州
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-3-26
收藏
得分:0 
前辈们,这题到底是怎么做的呀?我糊涂了~~
2008-03-27 11:49
快速回复:万分火急的求教,会的进C++简单运行结果题
数据加载中...
 
   



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

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