下载此文档

面向对象程序设计模拟题13填空和排错题.docx


文档分类:IT计算机 | 页数:约13页 举报非法文档有奖
1/13
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/13 下载此文档
文档列表 文档介绍
面向对象程序设计模拟题13填空和排错题.docx二、填空题(共 10 题,共 20 分)
1. 类成员的接见权限分为 __public___ 、 __protected_ 和 __private__ 三类。
(2 分)
以下语句序列履行st
{ cout<<"The point is ("<<x<<', '<<y<<')'<<endl; }
Line10:

private:
Line11:

int x,y=0;
Line12:
Line13:
Line14:
Line15:
Line16:
Line17:
Line18:

};
int main() {
Point p1,p2(2,1);
();
(1,4);
();
return 0;
Line19:

}
Line4: Point(int xx=0, int yy=1) : x(xx), y(yy) { }
Line5: void Move(int xOff, int yOff) {
Line11:int x,y;
二、填空题(共 10 题,共 20 分)
类的三种继承方式是 _公有继承( public ) ,保护继承( protect ),私有继承( private )。
2 分)
2. 以下语句序列的输出结果是 _120000_____ 。
(2 分)
class MyClass {
public:
MyClass(int x=0) { cout<<x; }
~MyClass() { cout<<0; }
};
int main() {
MyClass arr[3]={MyClass(1),MyClass(2)};
return 0;
}
3. 以下语句序列履行后输出 10,请将划线处的语句增补完好。 ( 2 分)
class MyClass {
public:
MyClass(int x) : _____val(x)____{ }
void Print( ) { cout<<val<<endl; }
private:
int val;
};
int main() {
MyClass obj(10);
();
return 0;
}
4. 请在划线处填写正确内容,使类 Test 的复制结构函数的申明完好。 ( 2 分)
class Test{
public:
Test(const __Test&_____obj);
};
5. 在 C++ 中, _函数重载 __是指同一个函数名能够对应多个函数的实现。
(2 分)
6. 请在划线处写出 MyClass 类的析构函数申明。
(2 分)
class MyClass {
public:
_____~ MyClass ();______
};
7. 以下语句序列履行后输出 Hello ,请将划线处的语句增补完好。 ( 2 分)
class MyClass {
public:
void Print() const { cout<<"Hello"; }
};
int main() {
MyClass* p = new MyClass();
p->Print();
return 0;
}
8. 运算符函数的函数名是由运算符前加重点字 _operator __ 组成

面向对象程序设计模拟题13填空和排错题 来自淘豆网www.taodocs.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数13
  • 收藏数0 收藏
  • 顶次数0
  • 上传人菲菲
  • 文件大小32 KB
  • 时间2022-01-23
最近更新