面向对象程序设计试题集

时间:2017-05-06 04:21:39
【文件属性】:
文件名称:面向对象程序设计试题集
文件大小:260KB
文件格式:DOC
更新时间:2017-05-06 04:21:39
试题集 一.阅读程序题 1. #include class CSample { int i; public: CSample() { i=1; cout< class Sample { private: int x; public: Sample(){ cout<<(x=0);} Sample(int i,int j) {cout<<(x=i+j);} ~Sample(){cout< class Sample { public: Sample(){} Sample(int a){x=a;} Sample(Sample &a){x=a.x++;} void disp(){cout< class Sample { int x; public: Sample(){x=0;} Sample(int a) {cout<<(x=a);} ~Sample() { cout<<++x; } void disp() { cout< class Sample { int x; public: Sample(){cout<<(x=0);} Sample(int i){cout<<(x=i);} ~Sample(){cout< class Sample { public: Sample(){cout<<"Constructor"< float f(float x, float y) { return x+y; } int f(int x, int y) { return x+y; } void main() { float a, b, c; a = b = 50.5; c = f(a, b); cout << c; } 10. #include int max(int x, int y) { if(x > y) return x; else return y; } int max(int x, int y, int z) { return max(x, max(y, z)); } void main() { int a = 3, b = 4, c = 5, d = 0; d = max(a, b); cout << d; } 11. #include int p(int x = 4, int y = 5) { return x + y; } void main() { int a = 3, b = 4, c = 0; c = p(b); cout << c; } 12. #include int add(int x, int y = 8); void main() { int a = 6; cout << add(a, add(a)) << endl; } int add(int x, int y) { return x + y; } 13. #include int p(int x = 4, int y = 5, int z = 6) { return x + y + z; } void main() { int a = 3, b = 4, c = 5; c = p(b, a); cout << c; } 14. #include int p(int x = 4, int y = 5, int z = 6) { return x + y + z; } void main() { int a = 3, b = 4, c = 0; c = p(b, c); cout << c; } 15. #include int n = 1; void Fun(); void main() { n++; Fun(); if(n > 0) { int n = 5; cout<< "Block:n=" << n << ","; } cout << "Main:n = " < 立即下载

网友评论