已知函数定义def demo(x,y,op):return eval(str(x)+op+str(y)),那么表达式demo(3,5,’-’)的值为()。
第1题:
( 9 )有如下的函数定义:
int Xfun(int x){
int y=x;
{int x=10; y+=x;}
return x+y;
}
通过表达式 Xfun(5) 调用该函数,则得到的返回值为 【 9 】 。
第2题:
有下列函数定义: int fun(double a,double b) {return a*b;} 若下列选项中所用变量都已经正确定义并赋值,错误的函数调用是( )。
A.if(fun(x,y)){……}
B.z=fun(fun(x,y),fun(x,y));
C.z=fun(fun(X,y)x,y);
D.fun(x,y);
第3题:
a. static
b. int
c. f1
d. return
第4题:
有如下函数模板定义: template <class T> T func(T x, T y){return x*x*y*y;) 在下列对func的调用中,错误的是
A.func(3,5);
B.func(3.0,5.5);
C.func(3,5.5);
D.func<int>(3,5.5);
第5题:
有如下函数模板定义: template<class t> T func(Tx,Ty){return x*x+y*y;} 在下列对func的调用中,错误的是
A.func(3,5);
B.func(3.0,5.5);
C.func(3,5.5);
D.func<int>(3,5.5)
第6题:
下列函数定义中,会出现编译错误的是 ______。
A.max(int x,int y,int *z) { *z=x>y? x:y;}
B.int max(int x,y) {int z; z=x>y? x;y; return z; }
C.max(int x,int y) { int z; z=x>y? x:y; return(z); }
D.int max(int x,int y) { return(x>y?x:y);}
第7题:
下列函数定义中,会出现编译错误的是
A.max(int x,int y,int *z) { *z=x>y ? x:y; }
B.int max(int x,y) { int z; z=x>y ? x:y; return z; }
C.max(int x,int y) { int z; z=x>y?x:y; return(z); }
D.int max(int x,int y) { return(x>y?x:y); }
第8题:
有如下程序: #include<iostream> using namespace std; class Demo { public: Demo(){ cout<<"default constructor\n";} Demo(const Demo & x){ cout<<"copy constructor\n":} }; Demo userCode(Demo b){DemoC(b);return c;} int main() { Demo a,d; cout<<"calling userCode()\n"; d=userCode(a); return 0; } 执行上面程序的过程中,构造函数Demo()和Demo(const Demo &x)被调用的次数分别是
A.1和1
B.1和2
C.2和3
D.2和4
第9题:
下列函数定义中,会出现编译错误的是
A.max(int x,int y,int*z) {*z=x>y?xy;}
B.int max(int x,y) {int z; z=x>y?xy; return z; }
C.max(int x,int y) {int z; z=x>y?xy;return(z); }
D.int max(int x,int y) { return(x>y?xy);}
第10题:
对下列程序的描述正确的是( )。 #include <iostream> using namespace std; int fuc(int,int); int main(){ cout<<fuc(1,10)<<endl; return 0; } int fuc(int x,int y){ return x*x+y*y; }
A.该函数的定义和调用方式都是错误的
B.该函数的定义和调用方式都是正确的
C.该函数调用方式正确,但函数定义错误
D.函数定义正确,但函数调用方式错误