上海大学2014~2015学年度秋季学期试卷(a卷)
课程名: 面向对象程序设计课程号: 08305121 学分: 5
应试人声明:
我保证遵守《上海大学学生手册》中的《上海大学考场规则》,如有考试违纪、作弊行为,愿意接受《上海大学学生考试违纪、作弊行为界定及处分规定》的纪律处分。
应试人应试人学号应试人所在院系。
一、判断题(每小题2分,共20分)
1. 引用在声明时必须对其初始化,以绑定某个已经存在的变量(或对象),在该引用的生命期内,该绑定不能被更改。 (
2. 指针变量在定义时必须对其初始化,以锁定某个已经存在的目标变量(或。
对象),在该指针变量的生命期内,该指向不能被更改。 (
3. 值返回的函数(如:double sqrt(double);)的调用表达式(如:
sqrt(2.0))代表一个无名的临时变量(或对象),一般不将其用作左值。 (
4. 引用返回的函数,可以返回该函数中值传递的形参变量(或对象)。
5. 任何类都有构造函数、复制构造函数、析构函数、赋值运算符函数。 (
6. 有静态数据成员的类,一般地应该考虑为其设计复制构造函数、析构函数。 (
7. 将用于输出的插入运算符函数operator《设计成友元函数的根本原因是。
因为进行输出操作时需要访问对象的内部数据成员。 (
8. 在c++程序中,操作符new的功能与calloc函数的功能完全一样。 (
9. 创建一个c++字符串对象(如:string str;),则sizeof(str)的值。
等于的值。其中成员函数length为返回字符串的长度。 (
10. 基类的私有数据成员在派生类中是存在的,但不可直接访问,需要用从基类。
继承下来的函数访问。 (
二、填空题(每空2分,共30分)如下设计了结点类node、链表类linklist,并将链表类作为结点类的友类,请根据运行结果,完成程序。
#include
using namespace std;
class ① linklist提前声明。
class node
public:
node(int x=0) :data(x) {
② friend class linklist;
private:
int data;
node ③ next ;
class linklist
private:
node *head;
public:
linklist(int n=0, int *array=null)
linklist(const linklist &link)
virtual ~linklist()
⑦ linklist & operator=(const linklist &link)
q->next = null ;
return *this;
void freelist()
void showlist(ostream &out) const
ostream & operator<<(ostream &out, const linklist &link)
out );
return out ;
int main()
int n, a
n = sizeof(a)/sizeof(*a);
linklist linka(n, a), linkb(linka), linkc;
cout < linkc = linka; cout < return 0; 三、阅读程序写出运行结果(每行1分,共25分) 1. (7分)有关构造与析构的顺序。 #include using namespace std; class test public: test(int a=0, int b=0): x(a), y(b) { ~test() friend ostream & operator<<(ostream &out, const test &t) private: int x, y; int main() test *p, t1; p = new test(10); test t2(2, 3); cout <
< t1 < < t2 < delete p; cout <<退出程序,返回操作系统" return 0; 2. 以下两小题所涉及的类设计,头文件如下。 #include #include using namespace std; class base public: base(double x=0, double y=0): x(x), y(y) { virtual void show(ostream &out) const = 0; protected: double _x, _y; ostream & operator<<(ostream &out, const base &x) return out; class complex : public base public: complex(double x=0, double y=0): base(x, y) void show(ostream &out) constelse friend complex operator+(const complex &a, const complex &b) friend complex operator*(const complex &a, const complex &b) double abs() class point : public base public: point(double x=0, double y=0): base(x, y) void show(ostream &out) const friend point operator+(const point &a, const point &b) point c; c._x = a._x + b._x; 2013年春季2013级期末考试试题。科目 铁道综合 总分300分,考试时间150分钟 1 铁路信号可以分为两大类。2 上行进站信号机用 表示,下行进站信号机用 表示。3 gsm r指的是。4 tocs指的是。5 全国列车第六次是在年月日,提速后的运行速度可达。6 信号机按类型可分为。7 车站信号基... 2013年春季2013级期末考试试题。科目 汽修综合卷 总分300分,考试时间150分钟 一 填空题 每空3分,共153分 1 汽车电气设备按其功能可分为系统系统系统系统系统系统系统系统。2 蓄电池的正极板表面的活性物质是颜色,呈负极板表面的活性物质是颜色,呈。3 蓄电池主要由。等组成。4 发动机主... 2013年春季2013级期末考试试题。科目 电子专业综合卷 总分300分,考试时间150分钟 一 选择题 每个选项只有一个正确答案,每小题4分,共80分 1 发光二极管正常工作时,应在二极管两端加上 电压。a 正向 b 反向 c 正向反向都可以 d 无法判定。2 测得一只二极管的正向反向电阻值都为无...13级铁道试题
13级汽修试题
13级电子试题