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

当前位置:首页 > C++期末复习题库

C++期末复习题库

  • 62 次阅读
  • 3 次下载
  • 2025/5/23 18:18:24

void main( ){ f a; a.f1(1,3); a.get ( );

} private:int x=0,y=0; 数据成员声明时不允许直接赋值 44.#include class point{private:float x; public:void f(float a){x=a;} void f( ){x=0;}

friend float max(point& a,point& b); };

float max(point& a,point& b) {return(a.x>b.x)? a.x:b.x;} void main( ){ point a,b; a.f(2.2);b.f(3.3); cout<

} cout<

45.#include template class f{

private:T x,y;

public:void f1(T a,T b){x=a;y=b;} T max( ){retum(x>y)?x:y;} };

void main( ){ f a;

a.f1(1.5,3.8);

cout<

} cout<

四、完成程序题(本大题共5小题,每小题4分,共20分) 46.完成下面类中的成员函数的定义。 class point { private: int m,n; public: point(int,int); point(point&); };

point::point(int a,int b) {

m=a; ______ n __=b; }

point::point(____point&t ____) { m=t.m; n=t.n; }

47.下面是一个输入半径,输出其面积和周长的C++程序,在下划线处填上正确的语句。 #include using namespace std;

____ const double ____pi=3.14159; void main( ) {

double r; cout<<″r=″; ____ cin>>r _______ ; double l=2.0*pi*r; double s=pi*r*r;

cout<<″\n The long is:″<

}

48.在下划线处填上缺少的部分。 #include #include using namespace std; class complex { public: int real; int imag;

complex(int r=0,int i=0) {

real=r; imag=i; } };

complex operator+(___ complex&a _____, {

int r=a.real+b.real; int i=a.imag+b.imag;

return____ complex(r,i) _____; }

complex& b)

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

共分享92篇相关文档

文档简介:

void main( ){ f a; a.f1(1,3); a.get ( ); } private:int x=0,y=0; 数据成员声明时不允许直接赋值 44.#include class point{private:float x; public:void f(float a){x=a;} void f( ){x=0;} friend float max(point& a,point& b); }; float max(point& a,point& b) {return(a.x>b.x)? a.x:b.x;} void main( ){ point a,b; a.f(2.2);b.f(3.

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价: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