云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 习题1

习题1

  • 62 次阅读
  • 3 次下载
  • 2025/12/2 21:43:42

int gety() {return y;} private: int x, y; };

int A::f1() {return x+y;} int A::f2() {return x-y;} void main() {

A a;

a.setx(10); a.sety(5);

cout<

4、

# include class T { public:

T(int x, int y) {

a=x; b=y;

cout<<”diao yong gou zao han shu 1.”<

} T(T &d)

{

9

cout<<”diao yong gou zao han shu 2.”<

cout<< d.a<<’\\t’<

} ~T() {cout<<”diao yong xi gou han shu.”<

int add(int x,int y=10) {return x+y;}

private: int a,b; };

void main() {

T d1(4,8);

T d2(d1);

cout<

}

diao yong gou zao han shu 1. 4 8

diao yong gou zao han shu 2. 4 8 20 20

diao yong xi gou han shu. diao yong xi gou han shu.

5、

#include class A { int a;

double b;

public:

10

A(int x=100,double y=1.2){a=x;b=y;} void show(char *pt) { cout<

}

};

void main() { A obj1,obj2(100,3.5); obj1.show(\ obj2.show(\ A *p; p=&obj1;

p->show(\ (*p).show(\ p=&obj2;

p->show(\

(*p).show(\ p=new A;

p->show(\ delete p;

}

6、

#include class K { public:

int x;

11

K (int i){x=i;}

void fun1(int j){x+=j;cout<<\ void fun2(int j){x+=j;cout<<\

};

void main() { K c1(3),c2(6);

void(K::*pfun)(int)=K::fun1; (c1.*pfun)(6); pfun=K::fun2; (c2.*pfun)(12);

}

7、

#include using namespace std; class TIME; class DATE { public: DATE(int a=2004,int m=9,int b=23) { year=a; month=m; day=b;

}

void DateTime(TIME &t);

private: int year,month,day;

};

class TIME { public:

12

搜索更多关于: 习题1 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

int gety() {return y;} private: int x, y; }; int A::f1() {return x+y;} int A::f2() {return x-y;} void main() { A a; a.setx(10); a.sety(5); cout<

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com