通过海量题库、编程比赛和实时排名,系统化提升您的编程能力。
"C语言试卷" 试卷中 杭州电子科技大学面向对象程序设计试卷 中有题目如下:
第1题
写出下面程序的执行结果:
1)
#include <iostream> using namespace std; class A { friend double count(A&); public: A(double t, double r):total(t),rate(r){} private: double total; double rate; }; double count(A& a) { a. total+=a.rate*a.total; return a.total; } int main(void) { A x(80,0.5),y(100,0.2); cout<<count(x)<<','<<count(y)<<'\n'; cout<<count(x)<<'\n';return 0; }
2)
#include<iostream> using namespace std; class Count { private: static int counter; int obj_id; public: Count(); //constructor static void display_total(); //static function void display(); ~Count(); //destructor }; int Count::counter; //definition of static data member Count::Count() //constructor { counter++; obj_id = counter; } Count::~Count() //destructor { counter--; cout<<"Object number "<<obj_id<<" being destroyed\n"; } void Count::display_total() //static function { cout <<"Number of objects created is = "<<counter<<endl; } void Count::display() { cout << "Object ID is "<<obj_id<<endl; } int main(void) { Count a1; Count::display_total(); Count a2, a3,a4; Count::display_total(); a2.display(); a4.display(); return 0; }
3)
#include <iostream > using namespace std; class BASE { char c; public: BASE(char n):c(n){} virtual ~BASE(){cout<<c;} }; class DERIVED:public BASE { char c; public: DERIVED(char n):BASE(n+1),c(n){} ~DERIVED(){cout<<c;} }; int main(void) { DERIVED('X'); return 0; }
120,120 180
Number of objects created is = 1 Number of objects created is = 4 Object ID is 2 Object ID is 4 Object number 4 being destroyed Object number 3 being destroyed Object number 2 being destroyed Object number 1 being destroyed
所属试卷:杭州电子科技大学面向对象程序设计试卷
要定义一个引用变量p,使之引用类MyClass的一个对
六边形绘制。使用 turtle 库,绘制一个边长值为
关系数据库管理系统所管理的关系是( )。
设有以下定义:则以下叙述正确的是。
有如下程序程序运行后的输出结果是。
输出如下格式的九九乘法表:1*1=12*1=2 2*2
当作力条件表达式时,{}与None等价。
己知x为非空字符串,那么表达式‘ ’. join(x.
表达式 0 or 5 的值为_________。
对文件进行写入操作之后,_______方法用来在不关闭
已知字典 x={i:str(i+3) for i in
与十进制数 1770.625 对应的八进制数是____
若有定义int b=7;float a=2.5;c=4
以下程序的功能是
以通信子网为中心的计算机网络称为( )
现在需要统计当前目录/home/zheng下普通文件的
参照完整性要求外码的值必须取 ,或等于被参照关系
创建外键约束时,如果要使删除父表记录时子表对应记录外键
用向量和单链表表示的有序表均可使用折半查找方法来提高查
2023年CSP-S1阅读程序题1:假设输入的x是不超
已知头指针h指向一个带头结点的非空单循环链表,结点结构
软件生存周期一般可分为 、可行性研究、 、设计
定义int a[2][3];,表示数组a中的元素个数是
预处理命令行都必须以_____号开始。
有以下程序程序运行后的输出结果是
若有定义语句:double x,y,*px,*py;执
(矩阵变换)有一个奇幻的矩阵,在不停的变幻,其变幻方式
二进制数 00100100 和 00010101 的和
记 T 为一队列初始为空现有 n 个总和不超过 32
输出: ________________
更多选择题
更多填空题
第十章 C++流
第九章 C++模板
第八章 C++运算符重载
C++语言程序设计真题5
C++语言程序设计真题4
C++语言程序设计真题3
C++语言程序设计真题2