网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

假设有一个函数声明: int max1(int a, int b) {return a > b? a: b;} 则为了提高程序运行效率,应该将它声明为()

A.内联函数

B.重载函数

C.友元函数

D.递归函数


参考答案和解析
内联函数
更多 “假设有一个函数声明: int max1(int a, int b) {return a > b? a: b;} 则为了提高程序运行效率,应该将它声明为()A.内联函数B.重载函数C.友元函数D.递归函数” 相关考题
考题 若有以下函数首部int fun(double x[10], int *n)则下面针对此函数的函数声明语句中正确的是A)int fun(double x, int *n);B)int fun(double , int );C)int fun(double *x, int n);D)int fun(double *, int *);

考题 请将以下程序中的函数声明语句补充完整#include stdio.hint【12】 ;main( ){int x,y,(*p)();p=max;printf(“d\n”,x,y);}Int max(int a,int b){return (ab/a:b);}

考题 请将以下程序中的函数声明语句补充完整。#include stdio.hint 【 1 2 】 ;main(){ int x,y,(*p)();scanf("%d%d",x,y);p=max;printf("%d\n",(*p)(x,y));}int max(int a,int b){ return(ab?a:b);}

考题 已知:double A(double A){return++a;}和int A(int a){return ++a;)是一个函数模板的两个实例,则该函数模板定义为【 】。

考题 若已经声明了函数原型“void fun(int a,double b=0.0);”,则下列重载函数声明中正确的是( )。A.void fun(int a=90,double b=0.0);B.int fun(int a,double B);C.void fun(double a,int B);D.bool fun(int a,double b=0.0);

考题 有如下类声明: class MyBASE { int k: public; void set(int n){k=n;} int get() const{return k;} }; class MyDERIVED: protected MyBASE { protected: int j; public: void set(int m, int n){MyBASE::set(m);j=n;} int get() const{return MyBASE::get()+j;} }; 则类MyDERIVED中保护的数据成员和成员函数的个数是( )。A.4B.3C.2D.1

考题 已知一函数的形参说明为int arr[5][6],则与此等效的形参说明为A.int arr[][]B.int[5][]C.int*a[6]D.int(*a)[6]

考题 下列函数的功能是【 】。include int Func(int a,int b) {if (a>b) return 1; else if 下列函数的功能是【 】。include<iostream. h>int Func(int a,int b){if (a>b) return 1;else if(a==b) return 0;else return -1;}

考题 有以下程序int fa(int x){return x*x;}int fb(int x){return x*x*x;}int f(int(*fl)(),int(*f2)(),int x}{return f2(x)-f1(x);}main(){int i;i=f(fa,fb,2);printf("%d\n",i);}程序运行后,输出结果是【 】。

考题 阅读下面程序: include using namespace std; int fun(int a,int b) {int c;c = a * 阅读下面程序:include <iostream>using namespace std;int fun( int a, int b){int c;c = a * b;return c;}int main ( ){int a = 3, b = 5, c = 4, x = O;x = fun( fun( a, b ), c );cout<<x<<end1;return 0;}其运行结果是【 】。

考题 有以下程序:includeusing namespace Std;inta;int fun();int main(){ externinta; in 有以下程序: #include <iostream> using namespace Std; int a; int fun(); int main() { extern int a; int b; a = 100; b = fun(); cout<<b<<end1; return 0; } int fun() { extern int a; return (10*A); } 其程序运行后的输出结果是( )。A.100B.10C.1000D.10000

考题 有如下类声明: class MyBASE{ int k; public: void set(iht n){k=n;} int get()coast{return k;} }; class MyDERIVED:pnoted My BASE { protected: int j; public: void set(int m,int n){MyBASE::set(m);j=n;} int get()const{return MyBASE::get()+j;} }; 则类MyDERIVED中保护的数据成员和成员函数的个数是A.4B.3C.2D.1

考题 有如下的运算符重载函数定义:double operator+(int i,int k){return double(i+k);}但定义有错误,对这个错误最准确的描述是( )。A.#NAME?B.两个int型参数的和也应该是int型,而这里将+的返回类型声明为doubleC.没有将运算符重载函数声明为某个类的友元D.C++已经提供了求两个int型数据之和的运算符+,不能再定义同样的运算符

考题 有如下类声明: class MyBASE{ int k; public: void set(int n){k=n;} int get( )const{return k;} }; class MyDERIVED:protected MyBASE{ protected: intj; public: void set(int m,int n){MyBASE::set(m);j=n;} int get( )const{return MyBASE::get( )+j;} }; 则类MyDERIVED中保护的数据成员和成员函数的个数是A.4B.3C.2D.1

考题 请将以下程序中的函数声明语补充完整。 include int【】 main(){int x,y,(*p)(); sccanf(" 请将以下程序中的函数声明语补充完整。include<stdio.h>int【 】main(){ int x,y,(*p)();sccanf("%d%d",x,y);p=max;printf(%d\n",(*p)(x,y));}int max(int a,int b){return(a>b?a:b);}

考题 若有以下函数首部: int fun(double x[10],int *n) 则下面针对此函数的函数声明语句中正确的是( )。A.int fun(double x, int *n);B.int fun(double, int);C.int fun(double *x, int n);D.int fun(double*, int*);

考题 对下列程序的描述正确的是()。include using namespace std;int fuc(int,int);int mai 对下列程序的描述正确的是( )。 #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.函数定义正确,但函数调用方式错误

考题 阅读以下函数说明和C语言函数,将应填入(n)处的字句写在答题纸的对应栏内。【函数2.1说明】递归函数sum(int a[], int n)的返回值是数组a[]的前n个元素之和。【函数2.1】int sum (int a[],int n){if(n>0) return (1);else (2);}【函数2.2说明】有3个整数,设计函数compare(int a,int b,int c)求其中最大的数。【函数2.2】int compare (int a, int b, int c ){ int temp, max;(3) a:b;(4) temp:c;}【函数2.3说明】递归函数dec(int a[],int n)判断数组a[]的前n个元素是否是不递增的。不递增返回 1,否则返回0。【函数2.3】int dec( int a[], int n ){if(n<=1) return 1;if(a[0]<a[1]) return 0;return (5);}

考题 有以下程序 include int fun(int a, int b) { if(b==0) return a; 有以下程序 #include <stdio.h> int fun(int a, int b) { if(b==0) return a; else return(fun(-a,-b)); } main() { printf("%d\n",fun(4,2)); } 程序的运行结果是______。A.1B.2C.3D.4

考题 将下面程序补充完整。 include using namespace std; class Base{ public: 【 】fun(){r 将下面程序补充完整。include <iostream>using namespace std;class Base{public:【 】 fun(){return 0;} //声明虚函数};class Derived:public Base{public:x,y;void SetVal(int a,int b){}int fun(){return x+y;}};void 【 】 SetVal(int a,int b){x=a;y=b;} //类Derived成员函数void main(){Derived d;cout<<d.fun()<<endl;}

考题 下列函数的运行结果是()。includeint add(int a,int b);void main(){extern int x,y 下列函数的运行结果是( )。 #include<iostream.h> int add(int a,int b); void main() { extern int x,y; cout<<add(x,y)(<endl; ) int x(20),y(5); int add(int a,intB) { int s=a+b; return s; }A.25B.30C.20D.15

考题 有以下程序includeusing namespace std;int a;int fun();int main(){extern int a;in 有以下程序 #include<iostream> using namespace std; int a; int fun(); int main() { extern int a; int b; a=100; b=fun(); cout<<b<<endl; return 0; } int fun() { extern int a; return(10*a); } 其程序运行后的输出结果是( )。A.100B.10C.1000D.10000

考题 下面函数的运行结果是( )。 include using namespace std; class A{ pu 下面函数的运行结果是( )。 #include <iostream> using namespace std; class A{ public: A(){} int Min(int a,int b){return a<b? a:b;} int Min(int a,int b,int c){ if(a<b)return a<c? a:c; else return b<c? b:c; } ~A(){} }; void main(){ A a; cout<<a.Min(1,2,3)<<a.Min(2,0); }A.10B.12C.30D.32

考题 有以下程序include using namespace std;int a;int fun ();int main (){extern int a 有以下程序#include <iostream>using namespace std;int a;int fun ();int main (){ extern int a; int b; a = 100; b = fun(); cout<<b<<end1; return 0;}int fun{){ extern int a; return (10*a ;} 其程序运行后的输出结果是A.100B.10C.1000D.10000

考题 下列函数的运行结果是()。includeint add(int a,int b);void main(){extem int x,y; 下列函数的运行结果是( )。 #include<iostream.h> int add(int a,int b); void main() { extem int x,y; cout<<add(x,y)<<endl; } int x(20),y(5); int add(int a,int b) { int s=a+b; return s; )A.25B.30C.20D.15

考题 对下列程序的描述中,正确的是()。includeusing namespace std;int Fun(int,int);int m 对下列程序的描述中,正确的是( )。 #include<iostream> using namespace std; int Fun(int,int); int main() { cout<<Fun(5,50)<<end1; return 0; } int Fun(int x,int y) { return x*x+y*y; }A.该函数定义正确,但函数调用方式错误B.该函数调用方式正确,但函数定义错误C.该函数的定义和调用方式都是正确的D.该函数的定义和调用方式都是错误的

考题 有如下的运算符重载函数定义:double operator+(int i,int k){return double (i+ k);}但定义有错误,对这个错误最准确的描述是( )。A.“+”只能作为成员函数重载,而这里的“+”是作为非成员函数重载的B.两个int型参数的和也应该是int型,而这里将“+”的返回类型声明为doubleC.没有将运算符重载函数声明为某个类的友元D.C++已经提供了求两个int型数据之和的运算符+,不能再定义同样的运算符

考题 已知一个函数的定义如下:double fun(int x,double y){⋯⋯}则该函数正确的函数原型声明为()A、double fun(intx,doubley)B、fun(int x,doubley)C、double fun(int,double);D、fun(x,y);