1、下列4行代码是否有错误,若有错误请指出,若没有,请确定a的值是多少?
int a = 3; a += (a++); a += (++a); (++a) += (a++); (a++) += a;2、下面代码的输出是多少?
int main(void) { FILE *fp; char str[100]; fp=fopen("myfile.dat","w"); fputs("abc",fp); fclose(fp); fp=fopen("myfile.data","a++"); fprintf(fp,"%d",28); rewind(fp); fscanf(fp,"%s",str); puts(str); fclose(fp); return 0; }3、下面代码的输出是(B)
class Myclass { public: Myclass(int n) { number = n;} Myclass(Myclass &other) { number = other.number; cout<<"a "; } private: int number; }; Myclass fun(Myclass p) { Myclass temp(p); return temp; } int main(void) { Myclass obj1(10),obj2(0); Myclass obj3(obj1); obj2=fun(obj3); return 0; }A、a a a B、a a a a C、a a D、a
定义对象obj3的时候,调用了对象赋值函数,输出了a,调用函数fun的时候,先调用对象赋值函数把对象obj3赋值给了p,然后又一次调用对象赋值函数赋值给了temp对象,最后把函数返回值又赋值给了对象obj2,共调用了4次,所以输出了4个a。
4、下面代码的输出是(A)
class Myclass { public: Myclass(int n) { number = n;} Myclass(Myclass &other) { number = other.number; cout<<"a "; } private: int number; }; Myclass fun(Myclass &p) { Myclass temp(p); return temp; } int main(void) { Myclass obj1(10),obj2(0); Myclass obj3(obj1); obj2=fun(obj3); return 0; }A、a a a B、a a a a C、a a D、a
由于函数fun的是传引用参数,没有进行对象的赋值,只是在函数内部进行了一次对象之间的赋值,所以比上一题少了一次调用,所以就输出了3个a。
5、下面错误的是()
A、define N 10;
int x[N];
B、int N = 10;
int x[N];
C、int x[0..10];
D、int x[];
简答题:
1、abstract class 和interface的区别?
2、数据库中索引的作用的什么?什么情况下适合建立索引及什么情况下不适合建立索引?
3、黑盒测试和白盒测试的优缺点各是什么?