logo资料库

C++语言程序设计期末复习题(含答案)(.pdf

第1页 / 共11页
第2页 / 共11页
第3页 / 共11页
第4页 / 共11页
第5页 / 共11页
第6页 / 共11页
第7页 / 共11页
第8页 / 共11页
资料共11页,剩余部分请下载后查看
C++语言程序设计期末复习题 一、单项选择题 1、面向对象程序设计数据与_____放在一起,作为一个相互依存、不可分割的整 体来处理。 A、对数据的操作 B、信息 C、数据隐藏 D、数据抽象 2、已知:int a=1,b=2,c=3,d=4,则表达式 a fuc( char* s) { char* p=s; while( *p) p++; return (p-s); } main() { cout<
make(); //... }; void B::make() { k=i*j; } 则上述定义中,_____是非法的表达式。 A、void get(); B、int k; C、void make(); D、k=i*j; 8、以下程序段_____。 C、循环执行 1 次 D 、 有 B、要求参数中至少有一个类型不同 B、循环执行 2 次 语法错误 9、对定义重载函数的下列要求中,_____是错误的。 A、要求参数的个数不同 C、要求参数个数相同时,参数类型不同 A、函数模板 D、要求函数的返回值不同 10、一个_____允许用户为类定义一种模式,使得类中的某些数据成员及某些成 员函数的返回值能取任意类型。 (Key:1-5:AAABC 二、填空题 1、在 C++类中可以包含[ ]、[ ]和[ ]三种具有不同访问控制权 的成员。(Key:公有或 public,保护或 protected,私有或 private) 2、以下程序的执行结果是_____。 B、模板函数 6-10:BDCDC) C、类模板 D、模板类 int x = -1; do { x = x*x; }while( !x ); A、是死循环 #include void func( int ); void func( double ); void main( ) { double a=88.18; func(a); int b=97; func(b); } void func( int x ) { cout<
cout< using namespace std; f(int b[],int n) { } int _tmain() { } int x,a[] = {2,3,4,5,6,7,8,9}; x=f(a,3); cout<<"x="< using namespace std; void sub( char a,char b ) { } void sub( char* a,char b ) { } void sub( char* a,char* b ) { char c=*a; *a=b; b=c; char c=*a; *a=*b;
*b=c; } int _tmain() { char a='A',b='B'; } sub(&a,&b); cout< using namespace std; void Exchange( int* pFirst,int* pLast ) { } void Print( int Integer[],int HowMany) { } int _tmain() { } int Integer[] = {1,2,3,4}; Exchange(&Integer[0],&Integer[3]); Print(Integer,4); return 0; for( int Index=0; Index using namespace std; int _tmain() { int nInteger = 5, &rInteger = nInteger; rInteger = nInteger+1;
cout< using namespace std; int _tmain() { } int x=2,y=3,z=4; cout<<(( x using namespace std; int _tmain() { int x=1,y=2,z=3; x+=y+=z; cout<<(x using namespace std; void func( int b[ ] ); void main() { int a[ ]={ 5,6,7,8 },i; func(a); for( i=0;i<4;i++ ) cout<
} i=0; Key: 0 2 4 6 3、#include using namespace std; class CSample { int i; public: CSample(void); ~CSample(void); CSample(int val); void Print(void); }; CSample::CSample(void) { cout<<"Constructor1"<
int nInteger; CData( int Integer ); ~CData( void ); void Print(void); 4、#include using namespace std; class CData { protected: public: }; CData::CData( int Integer ) : nInteger(Integer) { cout<<"Constructing a data"<
void CNumber::Print(void) { CData::Print(); cout<<"The number is "< using namespace std; int _tmain() { long Term=________________ ,Sum=________________; cout< using namespace std; class CShape { public: Term *=________________; Sum +=________________; return 0; CSquare::CSquare(double Width,double Height)
分享到:
收藏