通过海量题库、编程比赛和实时排名,系统化提升您的编程能力。
"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
所属试卷:杭州电子科技大学面向对象程序设计试卷
下列关于继承的描述中,错误的是。
已知类MyClass的定义如下,下列对MyClass类
表达式{1,2,3}&{3,4,5}的值为______
使用运算符测试集合包含集合A是否为集合B的真子集的表达
已知x={‘a’:’b’,’c’:’d’},那么表达式
编写程序实现功能:对于给定的一个百分制成绩,改用相应的
以下程序时将矩阵a、b的和存入矩阵c中并按矩阵形式输出
网络管理员对www服务器可进行访问、控制存取和运行等控
下面哪条命令可以把f1.txt复制为f2.txt?
在Windows的命令窗口中,以超级管理员身份连接My
在DBMS的授权子系统中,授权和回收权限的语句分别是G
curseek是已定义的游标,关闭该游标的语句为 __
下列数据中,( )是非线性数据结构。
设森林F对应的二叉树为B,它有m个结点,B的根为p,p
必须要由网络管理员手动配置的是
耦合性有哪几种类型?其耦合度的顺序如何?[答案解析]低
下列选项中,属于指令集体系结构(ISA)规定的内容是
若有定义:则C编译系统为数组s开辟_____个字节的内
功能:求给定正整数m以内的素数之和。例如:当m=20时
假设变量a、b均为整型,表达式(a=5,b=2,a>b
下列程序段的输出结果为( )。
对任何一个二维数组的元素,都可以用数组名和两个下标唯一
若在程序某处定义了某全局变量,但不是程序中的所有函数中
当输入为“Y3Nx”时,输出的第二行为( )。
需求分析阶段产生的主要文档是
有以下程序程序运行后的输出结果是
输入1:6 10 1 6 4 5 3 2输出1:___
(最大连续子段和) 给出一个数列(元素个数不多于 10
输出 :___________________
递归过程或函数调用时,处理参数和返回地址,通常使用一种
更多选择题
更多填空题
第十章 C++流
第九章 C++模板
第八章 C++运算符重载
C++语言程序设计真题5
C++语言程序设计真题4
C++语言程序设计真题3
C++语言程序设计真题2